Last active
August 16, 2020 19:08
-
-
Save moddingg33k/ee9d5fa6f76832ee9bf695ce0e27d80e to your computer and use it in GitHub Desktop.
Methods to mount a SMB share by PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$PsDriveParams = @{ | |
Name = 'Z'; | |
Root = '\\<fqdn>\<path>'; | |
Credential = (Get-Credential) | |
} | |
New-PSDrive @PsDriveParams -PSProvider FileSystem -Scope Global -Persist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$SmbMappingParams = @{ | |
LocalPath = 'Z:'; | |
RemotePath = '\\<fqdn>\<path>'; | |
UserName = '<NetbiosDomainName>\<samAccountName>'; | |
Password = 'P@ssw0rd' | |
} | |
New-SmbMapping @SmbMappingParams -Persistent $True -SaveCredentials |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$NetShare = New-Object -ComObject WScript.Network | |
$NetShare.MapNetworkDrive(strLocalDrive, strRemoteShare, [persistent], [strUser], [strPassword]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment