Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, March 9, 2017 5:24 PM
I'm trying to run a script to map a remote directory and copy files from it using the follow two line script:
New-PSDrive -Name J -PSProvider FileSystem -Root $remote -Credential $mycreds -Persist
Copy-Item -Path $remote -Destination $local -recurse
but i get the following exception
New-PSDrive : Access is deniedAt C:\bk1.ps1:8 char:5
- New-PSDrive -Name J -PSProvider FileSystem -Root $remote -Credential $mycred ...
-
+ CategoryInfo : InvalidOperation: (J:PSDriveInfo) [New-PSDrive], Win32Exception
+ FullyQualifiedErrorId : CouldNotMapNetworkDrive,Microsoft.PowerShell.Commands.NewPSDriveCommand
On the remote machine, when I change the add the user that I am using for this to the Admin group it works correctly so between that and the Access Denied, its clearly a permissions issue. This user has full permissions on the target folder so I dont think its a folder or file level issue.
So my question is what permissions are needed for New-PSDrive?
All replies (1)
Thursday, March 9, 2017 6:54 PM
There is no permission needed to use New-PsDrive. The permissions are required by the target system share and file system.
You do not need to create a drive to copy a file from or to a remote system. Just use the UNC path.
copy-item \remotepc\share\folder\file.ext c:\ -credential $cred
help copy-item -full
\(ツ)_/