Share via


The built-in SMB PowerShell aliases in Windows Server 2012 and Windows 8

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:

Alias Cmdlet
gsmbs Get-SmbShare
nsmbs New-SmbShare
rsmbs Remove-SmbShare
ssmbs Set-SmbShare
blsmba Block-SmbShareAccess
gsmba Get-SmbShareAccess
grsmba Grant-SmbShareAccess
rksmba Revoke-SmbShareAccess
ulsmba Unblock-SmbShareAccess
gsmbc Get-SmbConnection
gsmbm Get-SmbMapping
nsmbm New-SmbMapping
rsmbm Remove-SmbMapping
cssmbse Close-SmbSession
gsmbse Get-SmbSession
cssmbo Close-SmbOpenFile
gsmbo Get-SmbOpenFile
gsmbcc Get-SmbClientConfiguration
ssmbcc Set-SmbClientConfiguration
gsmbsc Get-SmbServerConfiguration
ssmbsc Set-SmbServerConfiguration
gsmbcn Get-SmbClientNetworkInterface
gsmbsn Get-SmbServerNetworkInterface
gsmbmc Get-SmbMultichannelConnection
udsmbmc Update-SmbMultichannelConnection
gsmbt Get-SmbMultichannelConstraint
nsmbt New-SmbMultichannelConstraint
rsmbt Remove-SmbMultichannelConstraint
gsmbw Get-SmbWitnessClient
msmbw Move-SmbWitnessClient

 

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:

Prefix Verb
Bl Block
Cs Close
G Get
Gr Grant
M Move
N New
R Remove
Rk Revoke
S Set
Ud Update
Ul Unblock

 

Here are the suffixes that we use in SMB Aliases, also in alphabetical order:

Suffix Noun
A ShareAccess
C Connection
CC ClientConfiguration
CN ClientNetworkInterface
M Mapping
MC MultichannelConnection
O OpenFile
S Share
SC ServerConfiguration
Se Session
SN ServerNetworkInterface
T MultichannelConstraint
W WitnessClient

 

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… :-)