Q. How can I map an SMB share using PowerShell?
A. To map an SMB shell using PowerShell utilize the New-SmbMapping cmdlet which also enables a username and password to be specified. For example:
New-SmbMapping -LocalPath X: -RemotePath \\10.10.10.1\Software -username 'savilltech\administrator' -Password 'Password'
Once connected applications can be executed from the new path (remember that a period (.) is required with PowerShell), for example:
.'X:\SQL Server\SQLServer2012SP3\Setup.exe' /ConfigurationFile="C:\Assets\ConfigurationFile.ini"
To disconnect you can use:
Remove-SmbMapping -LocalPath X: -Force
0 comments
Hide comments