PSremoting, Copy-Item and UNC paths RRS feed

  • Question

  • Hello All,

    I have a problem whereby I have written a script which works perfectly when ran locally but when I remote execute the script using the Invoke-command cmdlet it gives an error form the remote machine saying that the file I want to copy from the UNC path cannot be found.

    The file does exist on the UNC path and the script will work correctly should I log on to the same server and run the script from there.

    The script which i want to execute on a remote computer contains a line of code as follows:

    copy-item \\unc\path\to\ -destination "C:\Filelocation\"

    I then invoke the script using the following:

    Invoke-command RemoteComputerName -file "C:\scriptfile.ps1"
    I'm new to powershell but haven't heard anything that would explain this issue.

    Can anyone help?

    Wednesday, April 25, 2012 11:45 AM


All replies