Reputation: 2226
I have the need to run a Powershell command on a remote computer that will move a file from the remote computer to another computer on the network.
PS H:\> invoke-command -computername server1 -scriptblock {move-item c:\jobs\archive\A1051626.zip "
\\FilerServer\jobs\archive\"}
This command results in the following error:
Access to the path is denied. + CategoryInfo : PermissionDenied: (C:\jobs\archive\A1051626.zip:FileInfo) [Move-Item], Unauthorized AccessException + FullyQualifiedErrorId : MoveFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.MoveItemCommand
If I edit the PS command to copy the file to a local system folder the command runs fine.
The user account that I am running the PS script from on my local computer has permissions to copy files to the remote file server. I have double checked this, and I can mannually copy the files to the file share from Windows Explorer.
What is preventing the copy operation in PowerShell? How can I get this task to run?
Thanks!
Upvotes: 1
Views: 15554
Reputation: 301177
It is probably a double hop issue. You have to use CredSSP to delegate your credentials to the remote computer.
Try the solution mentioned here: http://blogs.msdn.com/b/clustering/archive/2009/06/25/9803001.aspx
Also, note that Move-Item may not work for moving from filesystem to network share. You might have to use Copy-Item
and Remove-Item
See this answer here: How do you move files/folders across volumes with Powershell?
Upvotes: 3