如何使用powershell映射驱动器

时间:2010-08-31 21:49:52

标签: powershell

如何在PowerShell上映射具有用户名和网络驱动器的网络驱动器;密码?

我正在尝试执行等效的命令提示符(cmd.exe)命令:

net use G: \\10.10.10.1\f$ /USER:prod\joe myStrongPasswordHere

我在下面的网站上找到了解决方案,但我在下面收到了错误消息。这是命令和错误:

$net = new-object -ComObject WScript.Network$net.MapNetworkDrive
("r:", "\\10.10.10.1\$f", $false, "prod\joe", "myStrongPasswordHere")
  

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

由于

1 个答案:

答案 0 :(得分:5)

老实说,我只会使用net use例如:

PS> net use G: \\10.10.10.1\f$ /USER:prod\joe myStrongPasswordHere