1 – Overview
Windows 8 and Windows Server 2012 introduced a new set of PowerShell cmdlets to manage File Servers and File Shares. If you’re not familiar with them, I would recommend reviewing my blog on The Basics of SMB PowerShell.
With the rule that cmdlets have to be written in a way that their purpose is obvious to the user, we sometimes end up with fairly lengthy cmdlets to type. There are two ways to overcome that: one is to use the <TAB> key while you type to autocomplete the cmdlet and the other is to use an alias.
An alias is basically an abbreviated form that maps one-to-one to the complete form of a cmdlet. For instance, if you want to get a list of SMB Shares, you can type just “gsmbs” instead of “Get-SmbShare”. Or, for a more compelling example, you can use just “gsmbsn” instead of “Get-SmbServerNetworkInterface”. You can also use the alias with the same parameters you use with the full cmdlet.
2 – The List of Aliases
Now, as you would expect from a blog like this, here is a complete list of the SMB PowerShell aliases and matching cmdlets:
3 – Don’t just Memorize. Learn!
Now, more important than memorizing the aliases is to understand the logic behind the way the aliases are created. While the SMB cmdlets are created with a verb, a dash, the term “Smb” and a noun, the SMB aliases are created using a prefix (which is an abbreviation of a verb), the term “smb” and a suffix (which is an abbreviation of a noun).
Here are the prefixes that we use in SMB aliases, in alphabetical order:
Here are the suffixes that we use in SMB Aliases, also in alphabetical order:
Now that you know the logic behind it, you can guess the aliases more easily. For instance, Get-SmbConnection is gsmbc (g=Get, smb, c=Connection). Also, Grant-SmbShareAccess is grsmba (gr=Grant, smb, a=ShareAccess).
4 – Conclusion
I have mixed feeling about aliases. If you’re writing a script that someone else will have to understand, the full form of the cmdlet is probably a better idea that would make your scripts more legible. In that case, using the <TAB> key can help with the typing. On the other hand they can be a great time saver while typing a quick cmdlet here and there. Use with care… 🙂