1

I have hundreds of computers on domain I am responsible for and I want to copy a file from a file server to their hard drives locally. If I script this to initiate the copy from my (separate) computer it works just fine via something like;

Copy-Item -LiteralPath \\FILESERVER01\Share\Files\Win7_64\File_to_copy.txt -Destination \\WORKSTATION01\c$\Users\USER\Desktop\ -Force }

However I'd like the script to initiate a copy from the file server to the workstation on the workstation via invoke-command so this isn't done on my machine using something (I assume is) like this:

Invoke-Command -ComputerName WORKSTATION01 -ScriptBlock { Copy-Item -LiteralPath \\FILESERVER01\Share\Files\Win7_64\File_to_copy.txt -Destination \\WORKSTATION01\c$\Users\USER\Desktop\ -Force }

But doing this consistently gives me the error citing the source as the issue - Cannot find path '\FILESERVER01\Share\Files\Win7_64\File_to_copy.txt' because it does not exist. I have access to this network shared path from all machines (via Domain Admin rights), so I believe this is something like a syntax error or problem with the way the UNC path is being resolved but despite reviewing several topics on this I just can't determine what I'm doing wrong with this since I'm using the same UNC paths in the same commands outside the invoke-command cmdlet (and from a PowerShell session on WORKSTATION01) with no issues.

I've tried reviewing and attempting solutions from this link, and also this link. But I can't tell if its a slightly different use case or if I just cant figure out how to adjust the syntax to make it work for me but the Cannot find path error persists

I've tried using New-PSDrive, prefixing the UNC path with "FileSystem:" and even taking the explicitly shared folders out entirely and using only the full path using administrative shares but I just seem to be missing something.

Can anyone shed some light on what I'm missing here?

Mr Roman
  • 17
  • 1
  • 5
  • This is the double hop problem. Here's [an article by Ashley McGlone on this issue](https://blogs.technet.microsoft.com/ashleymcglone/2016/08/30/powershell-remoting-kerberos-double-hop-solved-securely/) – BenH May 24 '17 at 20:06
  • 1
    Thank you for this, I was aware of the double-hop problem but I wasn't inclined to think that this was a scenario where it would manifest - I'm asking WORKSTATION01 to copy files from FILESERVER01 and I expected I might need to pass credentials to the WORKSTATION but I didn't realize my session would need to pass my credentials again since the share where the content is is fully open to authenticated users on the domain. I expected that WORKSTATION01 would use my credentials as domain admin, and that that would only be the first hop to initiate the copy - I guess I still have a lot to learn – Mr Roman May 25 '17 at 20:04
  • Which is why it's a double hop. The first hop (your credentials are used for) is to connect to the Client. The second is trying to use your credentials from the client to access the server. Which isn't allowed (normally). – Seth May 26 '17 at 17:29

0 Answers0