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

Best Practice: It is recommended to use full cmdlet name, do not use alias in scripts.

PowerShell

1

2

3

4

5

Alias(Bad)

gc-Path'C:\file.txt'

Command(Good)

Get-Content-Path'C:\file.txt'

Explanation: An alias is a an alternative shorter name for a cmdlet, function, script, file or executable file.
For instance, gc is the alias for the cmdlet Get-Content.

You can create an alias for a cmdlet using the following command :
New-Alias-Namegssfvc-ValueGet-SSFailoverVolumeContainers

You can list all the aliases (including the built-in aliases) with the cmdlet : Get-Alias

You can find the equivalence alias <> cmdlet:

Note: PowerShell includes an alias provider (acts as a file system drive)

Aliases can be used for the interactive Powershell console (they are useful to speed up our work), but not in scripts.
It takes more time to write the full cmdlet but your code will be more clear and consistent.

Let’s take an example, you publish a script on Internet and you used aliases into your script, it will be probably downloaded and used by thousands of users, the problem is that we never know in advance what aliases are defined on a foreign computer. If someone decided to change a built-in alias to another command or made a mistake when setting an alias, then the behaviour of the script becomes unpredictable and can lead to unexpected behaviour.

Moreover, some aliases are not so intuitive and it can be difficult to remember all of them.