New-SmbMapping

Create a mapping to an SMB share. Requires PowerShell 5.0+ and Windows 10
Early versions of this cmdlet were buggy but in PowerShell 5.1+ it is considered more robust than New-PSdrive.

Syntax
      New-SmbMapping [[-LocalPath] String] [[-RemotePath] String] [-CimSession CimSession[]]
         [-HomeFolder] [-Password String] [-Persistent Boolean] [-SaveCredentials] [-ThrottleLimit Int32]
            [-UserName String] [-whatIf] [-confirm] [CommonParameters]

Key
   -CimSession [CimSession[]]
       Run the cmdlet in a remote session or on a remote computer.
       Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet.
       The default is the current session on the local computer.
        
   -HomeFolder
       Indicates that the connection is made to the home folder of the user.
        
   -LocalPath [String]
       A local path to which the remote path is mapped.
       This is not limited to drive letters,any valid string may be used.
        
   -Password [String]
       A password to be used to connect to the SMB share.
        
   -Persistent [Boolean]
       Make this connection persistent.
        
   -RemotePath [String]
       The remote path that will be accessed from this computer.
        
   -SaveCredentials
       Save the credentials provided to use when another mapping to the same SMB server is created.
        
   -ThrottleLimit [Int32]
       The maximum number of concurrent operations that can be established to run the cmdlet.
       If this parameter is omitted or a value of 0 is entered, then PowerShell will calculate an optimum throttle limit 
       for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies 
       only to the current cmdlet, not to the session or to the computer.
        
   -UserName [String]
       The user name to use to connect to the SMB share.

   -whatIf
       Describe what would happen if you executed the command without
       actually executing the command.

   -confirm
       Prompt for confirmation before executing the command.

SMB versions

Version Available in Windows version: Support
SMB 1 Windows 2000 and WIndows XP Samba 1.x
Windows 10 (1909) removes support for SMB 1.0
SMB 2 Windows Server 2008 and Windows Vista SP1 Samba 3.6
SMB 2.1 Windows Server 2008 R2 and Windows 7 Samba 4.0.0
SMB 3.0 Windows Server 2012 / 2012 R2
Windows 8
Samba 4.2
SMB 3.02 Windows 8.1 / Windows 2012 R2 partial see wiki
SMB 3.11 Windows 10 / Windows 2016  

Examples

Create an SMB mapping:

PS C:\> New-SmbMapping -LocalPath 'X:' -RemotePath '\\Server64\Germany

  Status            Local Path         Remote Path 
  ------            ----------         ----------- 
  OK                X:                 \\Server64\Germany

“Businesses planned for service are apt to succeed; businesses planned for profit are apt to fail” ~ Nicholas M. Butler

Related PowerShell Cmdlets:

New-PSDrive - Create a mapped network drive (Windows 7).
Get-SmbConnection - Retrieve the connections established from the SMB client to the SMB servers.
Remove-SmbMapping - Remove an SMB Mapping
Windows cmd command: NET USE - Map drive.


 
Copyright © 1999-2020 SS64.com
Some rights reserved