Copying items between sessions

PowerShell 5 introduced the ability to copy between sessions using the Copy-Item command.

The FromSession parameter is used to copy a file to the local system:

$session1 = New-PSSession PSTest1 
Copy-Item -Path C:	empdoc.txt -Destination C:Temp -FromSession $session1 

In the preceding example, Path is on PSTest1.

The ToSession parameter is used to copy a file to a remote system:

$session2 = New-PSSession PSTest2 
Copy-Item -Path C:	empdoc.txt -Destination C:Temp -ToSession $session2 

In the previous example, the path used for the destination parameter is on PSTest2.

The FromSession and ToSession parameters cannot be specified together; two separate commands are required to copy a file between two remote sessions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.141.37