Copy To or From a PowerShell Session

Copy-Item now lets you copy to or from a PowerShell sessions in WMF5!



Very cool.

Let's see it in action. First of all, copy some local files to a remote session:

$TargetSession = New-PSSession -ComputerName HALOMEM03

Copy-Item -ToSession $TargetSession -Path "C:\Users\Administrator\desktop\scripts\" -Destination "C:\Users\administrator.HALO\desktop\" -Recurse



Now, copy some files from a remote session to the local server:

$SourceSession = New-PSSession -ComputerName HALODC01

Copy-Item -FromSession $SourceSession -Path "C:\Users\Administrator\desktop\scripts\" -Destination "C:\Users\administrator\desktop\" -Recurse



Don't Cross the Streams!

What about copying from one session to another?

Copy-Item -FromSession $SourceSession -ToSession $TargetSession -Path "C:\Users\Administrator\desktop\scripts\" -Destination "C:\Users\administrator\desktop\" -Recurse


Mutually exclusive parameters! Ah, well, you can't have it all...