How on PowerShell do 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