Welcome › Forums › General PowerShell Q&A › New-PSDrive error folder not found
- This topic has 1 reply, 2 voices, and was last updated 4 months, 2 weeks ago by
Senior Moderator.
-
AuthorPosts
-
-
September 3, 2020 at 6:52 am #254372
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 $CredThis 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.
Any ideas?
-
September 3, 2020 at 4:59 pm #254456
From your working server, as the user account that executes the script, what happens when you ping the target server?
What happens if you Get-ChildItem "\\server\share$" ?
-
-
AuthorPosts
- The topic ‘New-PSDrive error folder not found’ is closed to new replies.