BACK
TOP
The full guide of PowerShell that any developer needs to know – Naming Conventions
Matías Creimerman - Buenos Aires, Argentina - 2019-10-23

A naming conventions is a guide to write clean and maintainable code.

In PowerShell (PS) in general prefer to use full explicit names for commands and parameters rather than aliases or short forms.

Is important to use the universally known names rather your own aliases. In addition the most code programming tools highlight the common known commands and parameters.

For example, not use “gps -Name Explorer”, instead use “Get-Process -Name Explorer”.

Is very difficult to known all commands and parameters, so it’s important to be explicit about parameters.

For example, not use “Get-Process Explorer”, instead use “Get-Process -Name Explorer”.

When use paths, is very common to use “.” or “..” or some other options, but this is very difficult to find errors if you have problems with paths.  Avoid the use of “~”.

For example, not use “Get-Content .\README.md” or [System.IO.File]::ReadAllText(“.\README.md”), instead use “Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath README.md)” or “[System.IO.File]::ReadAllText(“$PSScriptRoot\README.md”)”

This content is property of Matias Creimerman
Any misuse of this material will be punishable
This work is licensed under a
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License
Creative Commons License