Efficient administration is all about following practices which are in line with the philosophy of the tool being used. In this chapter, the best practices are re-iterated so as to ensure that the reader remembers them, along with explanations to why they’re considered best practices.
Learn all the best practices pertaining to using PowerShell cmdlets
Learn the best practices in using parameter aliases, and how to declare and use them
Best practices pertaining to using calculated properties while querying information using one-liners
The best practices with parameters such as usage of named parameters and not using parameter aliases are covered. So is the use of parameter sets when creating functions.
This section talks about striking the right balance when it comes to using comments in scripts.
This section is all about choosing names using approved verbs and balancing readability and length.
When creating custom cmdlets, it is important that we add safety switches to system-altering capabilities.
Use regions to enable custom code folding and create boundaries around different blocks of code
Learn the best practices with respect to error handling
The expanding and literal strings
Call scripts without profiles to avoid configuration conflicts
This section aims to iterate the fact that PowerShell outputs objects and that’s where its power lies, as opposed to text.
This section also talks about how to strike a balance between readability and length, but with respect to variables.
Best practices pertaining to creating and declaring parameters in functions
Best practices in code indentation, braces and flow blocks such as begin, process, end, etc.
Sometimes using paths in scripts render them tightly coupled. Also, some usages may render the scripts unusable in some scenarios. This section gives administrators some of the right ways to use paths.
Remember that output from PowerShell is an object, and export the data accordingly