开发者

how to map a drive with powershell

开发者 https://www.devze.com 2023-01-14 20:47 出处:网络
How on PowerShell d开发者_如何学运维o I map a network drive with user name & password? I am trying to do an equivalent of command prompt (cmd.exe) command:

How on PowerShell d开发者_如何学运维o I map a network drive with user name & password?

I am trying to do an equivalent of command prompt (cmd.exe) command:

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

I found on this site solution below, but I get an error below. Here is command and error:

$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

Thanks


Honestly I would just use net use e.g.:

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

精彩评论

暂无评论...
验证码 换一张
取 消