Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

PSRemote Copy UNC, Script Block Remote Function

$
0
0

I'm writing a script that uses invoke-command to run some operations on a remote system. I need to copy a file from a server to the remote system.

When invoking the command on a remote system i'm unable to copy a file from a UNC path to the system that is being remoted into.

From the local host that is running the script not from a remote session I can copy the UNC path fine. Is it possible to call a function from an invoke-command script block to copy the file that is on a UNC path from the local host and then once that's done return back into the script block to continue to process the commands on the remote host?

function CopyUNC($host)

{

copy-item \\sbs\downloads\file.exe\\$host\C$\repository

}

invoke-command -computername powershell-xp2

{

copy-item \\sbs\downloads\file.exe C:\repository 

#^ this fails, I read because of authentication

#trying to do something like

$computer = hostname

CopyUNC($computer)

}

Thanks!

Zach

 


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>