Concept: A list of some Best Practices for Windows PowerShell.


PowerShell Best Practice #1: Use full cmdlet name (not alias)

PowerShell Best Practice #2: Use named parameter (not positional and partial parameter)

PowerShell Best Practice #3: Avoid Write-Host

PowerShell Best Practice #4: Use CIM cmdlet (not WMI cmdlet)

PowerShell Best Practice #5: Avoid excessive and useless inline comments

PowerShell Best Practice #6: Use singular noun (not plural noun)

PowerShell Best Practice #7: Use approved verb (not unapproved verb)

PowerShell Best Practice #8: Use WhatIf and Confirm parameters

PowerShell Best Practice #9: Use custom folding regions

PowerShell Best Practice #10: Avoid empty Catch block

PowerShell Best Practice #11: Use Set-StrictMode

PowerShell Best Practice #12: Avoid Out-Null

PowerShell Best Practice #13: Avoid double quotes in strings if not necessary

PowerShell Best Practice #14: Specify the extension for applications

PowerShell Best Practice #15: Execute scripts with -NoProfile parameter

PowerShell Best Practice #16: Update the help

PowerShell Best Practice #17: Use the same parameter name than the native one

PowerShell Best Practice #18: Don’t use Notepad as a script editor

PowerShell Best Practice #19: Check parameters with PSBoundParameters

PowerShell Best Practice #20: Use full key name for calculated properties

PowerShell Best Practice #21: Use #Requires statement

PowerShell Best Practice #22: Use a parameter alias for backwards compatibility

PowerShell Best Practice #23: Avoid the horizontal scrolling (too long one-liners commands)

Leave a Reply

Your email address will not be published. Required fields are marked *