Hi all. I’m trying to use New-PSDrive to map a network location to the powershell session, all part of some server build scripts. However, I’ve had to revert back to ‘net use’ as New-PSDrive seems a little broken to me - or rather, the way it works is different to what is written in the TechNet article on it (or I’m missing something that isnt mentioned on there).
Here’s my command:
$AdminUser = “domain\user”
$AdminPass = ConvertTo-SecureString -String ‘p4ssw0rd’ -AsPlainText -Force
$Cred = New-Object pscredential -ArgumentList $AdminUser,$AdminPass
New-PSDrive -Name “scripts” -PSProvider “FileSystem” -Root “\server\share$” -Credential $Cred
This gives me an error which I dont understand:
The specified root “\server\share$” either does not exist, or it is not a folder.
This seems like a nonsense error to me, since I can browse to that folder from the very same server I am running this command from, and even net use works fine with that folder. I have had to switch to net use, but would ideally prefer to use PS commands.