文章分类

当前位置:首页>文章中心>服务器相关>Powershell挂载SMB共享存储

Powershell挂载SMB共享存储

发布时间:2022-04-14 点击数:869

挂载脚本

# Define clear text string for username and password

[string]$userName = 'workshop\ParkData'

[string]$userPassword = 'Ml12345678'

# Convert to SecureString

[securestring]$secStringPassword = ConvertTo-SecureString $userPassword -AsPlainText -Force

[pscredential]$credObject = New-Object System.Management.Automation.PSCredential ($userName, $secStringPassword)

 

# Mount SMB share for container

New-SmbGlobalMapping -LocalPath z: -RemotePath \\192.168.3.247\ParkData -Persistent $true  -Credential $credObject



卸载脚本

Remove-SmbGlobalMapping -LocalPath z: