Better PowerShell Help (Part 3)

by May 17, 2021

In the previous tip we introduced the PowerShell “SmbShare” module which comes with Windows and enables you to manage file shares. We looked at the “SmbShare” noun which represents local folders that you share on a network. Today we’re looking at the “SbmMapping” noun.

The “SmbMapping” noun is looking at shares from the other end: it represents remote shares that you map as local drives. Get-SmbMapping lists all network drives you have mapped:

PS> Get-SmbMapping
Status       Local Path Remote Path
------       ---------- -----------
Disconnected Z:$
OK           Y:         storage3scanning

“New-SmbMapping” adds more network drives and maps drive letters to remote shared folders. Here is an example that maps a network drive and submits logon credentials as plain text:

PS> New-SmbMapping -LocalPath y: -RemotePath storage3scanning -UserName Freddy -Password topSecret123
Status Local Path Remote Path
------ ---------- -----------
OK     y:         storage3scanning

As always, it is a good idea to look at the cmdlet documentation to better understand how all of this works:

PS> Get-Help -Name New-SmbMapping -Online

This opens a documentation page in your default browser, and you can examine the available parameters and view additional examples.

You’ll discover the -Persistent switch parameter, for example. It determines whether the network drive will be persistent and available permanently, or just for the current session. -SaveCredentials would cache the entered logon credentials so the next time the remote share is accessed, the password is no longer required.

Twitter This Tip! ReTweet this Tip!