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

By | August 4, 2015

Best Practice: It is recommended to use the same name for your parameter (for your functions) than the native one parameter of the builtin Powershell cmdlets.

Explanation:

If you create a function which takes as a parameter a computerName, you should use the name : ComputerName
Why “ComputerName”? Because many builtin cmdlets use this parameter name so you should follow this standard.

powershell use same params native ones

However, you can use alias to handle these non-native parameters names (ex: Server, Computer, etc.)

It is useful to improve the readability and the understanding, if your parameter looks like a native one, there is no possible confusion.

If you call your parameter “PC” or “Comp”, it is less clear.


previous-buttonnext-button

2 thoughts on “Powershell Best Practice #17: Use the same parameter name than the native one

  1. Pingback: Powershell Best Practice #18: Don’t use Notepad as a script editor | Powershell Guru

  2. Pingback: Powershell Best Practice #16: Update the help | Powershell Guru

Leave a Reply

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