2010-08-31 111 views
2

如何在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

感謝

+0

您可能對serverfault更好的運氣 – JeremyWeir 2010-08-31 22:16:28

回答

5

老實說,我只想用net use例如爲:

PS> net use G: \\10.10.10.1\f$ /USER:prod\joe myStrongPasswordHere 
相關問題