Aliases and parameter names

The golden rule that you should adopt is to never use aliases again. There are surely good reasons for using them interactively, but please refrain from using them in your scripts, as your scripts will become nearly unreadable. Developers in .NET use obfuscation for those things; PowerShell handily offers up aliases to decrease the readability of scripts. We will further look at obfuscation in Chapter 7, Understanding PowerShell Security. Just ask yourself: Would you consider the following code sample readable?

# Does this look appealing to you? If so, perl might be your choice ;)
gsv | ? CanStop | spsv -ea SilentlyContinue -wh -pa

If you are using parameters, always write the parameter name. Not only will this make your code more readable to someone unfamiliar with it, but it will also prevent issues with ambiguous parameter sets after a cmdlet has been updated. There is no reason to not write the full parameter name, instead of the first unique characters; reserve this for the CLI only:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.118.95