Trouble with UNC paths and PowerShell sessions RRS feed

  • Question

  • Hello,

    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?

    • Moved by Bill_Stewart Friday, July 7, 2017 6:43 PM Use a GPO to distribute needed files
    Wednesday, May 24, 2017 7:18 PM

All replies

  • You cannot remotely access a third system.  Search for "second hop restriction" for more information.


    Wednesday, May 24, 2017 7:25 PM