如何在PowerShell上使用用户名和密码映射网络驱动器?
我正在尝试执行等效的命令提示符(cmd.exe)命令:
net use G: \\10.10.10.1\f$ /USER:prod\joe myStrongPasswordHere
Run Code Online (Sandbox Code Playgroud)
我在下面的网站上找到了解决方案,但我在下面收到错误.这是命令和错误:
$net = new-object -ComObject WScript.Network$net.MapNetworkDrive
("r:", "\\10.10.10.1\$f", $false, "prod\joe", "myStrongPasswordHere")
Run Code Online (Sandbox Code Playgroud)
New-Object : A positional parameter cannot be found that accepts argument 'System.Object []'. At line:1 char:18 + $net = new-object <<<< -ComObject WScript.Network$net.MapNetworkDrive ("r:", "\\10.10 .10.1\$f", $false, "prod\joe", "myStrongPasswordHere") + CategoryInfo : InvalidArgument: (:) [New-Object], ParameterBindingExcept ion + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands .NewObjectCommand
谢谢
powershell ×1