I am trying to create a powershell to connect to a network drive. I have researched various sources on the internet and Stack Overflow but has yet to work.
The script returns true to the Z drive folder existing but won't map to the network drive. The error I receive is
Exception calling "MapNetworkDrive" with "5" argument(s): "The specified device name is invalid.
All help would be greatly appreciated.
[System.IO.Directory]::Exists('Z:\Output');
$user = "domain\username"
$password = "password"
$drive = "Z:\"
$path = "\\Output"
$map = new-object -ComObject WScript.Network
$map.MapNetworkDrive($drive,$path ,$false, $user, $password)