New-PSDrive error folder not found

Welcome Forums General PowerShell Q&A New-PSDrive error folder not found

Viewing 1 reply thread
  • Author
    • #254372
      Topics: 9
      Replies: 20
      Points: 11
      Rank: 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.

      Any ideas?

    • #254456
      Senior Moderator
      Topics: 10
      Replies: 201
      Points: 1,096
      Helping Hand
      Rank: Community Hero

      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$" ?

Viewing 1 reply thread
  • The topic ‘New-PSDrive error folder not found’ is closed to new replies.