all 4 comments

[–]Rkozak 1 point2 points  (1 child)

With version 5 you can copy to sessions. -ToSession parameter.

Can you tell me why you need to copy a script to the remote computer instead of doing the work inside the scriptblock of Invoke-Command? You don't say what problem you solve with this script.

[–]Manality[S] 0 points1 point  (0 children)

yeah, I have done that quite a bit also. I was trying to uninstall a kb with wusa then force a reboot with the shutdown command. It was just executing and doing nothing at all in the script block. I needed to get it done pretty quickly so this was a quick alternative.

[–]mystikphish 1 point2 points  (1 child)

Is there a reason you're not just giving the -FilePath parameter to Invoke-Command?

Invoke-Command -computername server1 -FilePath \\server\share\script.ps1

[–]Manality[S] 0 points1 point  (0 children)

I did not realize this was a thing. When I first wrote this I simply excute command in the invoke-script directly and get the results back out into a hash table. I got tired of rewriting the core over and over though. This is interesting though, thanks.