Ok so I'm trying to map a network drive with a user name and password.
The issue I'm having is that the Get-creditial.password is not accepted as a parameter in Wscirpt.network.mapnetwork drive. This is the code I'm using
$cred = get-credential
$domain = "t2.local"
$user = $cred.UserName
$pwd = $cred.Password
$net = New-Object -com WScript.Network
$drive = "J:"
$path = "\\server\shared"
#$net.RemoveNetworkDrive($drive)
$net.mapnetworkdrive ($drive, $path, "true", $user, $pwd)
Now all works expect the $pwd variable. I'm guessing this is becuase Get-cred returns a system.security.securestring.
Is there a way to convert this?
The issue I'm having is that the Get-creditial.password is not accepted as a parameter in Wscirpt.network.mapnetwork drive. This is the code I'm using
$cred = get-credential
$domain = "t2.local"
$user = $cred.UserName
$pwd = $cred.Password
$net = New-Object -com WScript.Network
$drive = "J:"
$path = "\\server\shared"
#$net.RemoveNetworkDrive($drive)
$net.mapnetworkdrive ($drive, $path, "true", $user, $pwd)
Now all works expect the $pwd variable. I'm guessing this is becuase Get-cred returns a system.security.securestring.
Is there a way to convert this?