Best Practices


Description: List of best practices for Windows PowerShell


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

PowerShell Best Practice #2: Use named parameter in scripts (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 comments (over-commenting)

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

PowerShell Best Practice #7: Use approved verb for cmdlet (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 in your dev scripts

PowerShell Best Practice #12: Avoid Out-Null cmdlet

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 Obsolete attribute 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.