September 3, 2020 at 6:52 am #254372ParticipantTopics: 9Replies: 20Points: 11Rank: Member
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.
September 3, 2020 at 4:59 pm #254456Senior ModeratorTopics: 10Replies: 168Points: 899Rank: Major Contributor
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$" ?
- You must be logged in to reply to this topic.