Tuesday, June 2, 2015

Copy-Item improvements to support file copy over WinRM to NanoServers

If you follow this blog (you should!), then you know that I have just published a post on the procedure to install a Microsoft NanoServer.

If you read through the whole post, you know that this small footprint operating system is supposed to be managed through Powershell Remoting since it has no local logon capabilities.

Now, if you look well into the new cmdlets/parameters that come with the Windows Management Framework 5 (the one that comes with Windows 2016 TP2), you'll see that Copy-Item now supports file copy operations through WinRM.

The new key parameters are -ToSession and -FromSession.

Let's see with an example how they shoud be used., even do they are pretty self-explanatory.
First of all open a remoting session to the NanoServer:

$session = New-PSSession -ComputerName -Credential administrator
Then, to copy any file to the NanoServer over WinRM, just use the following syntax:

Copy-Item -ToSession $session -Path .\samplescript.ps1 -Destination c:\temp\
The operation can be performed both directions, so to retrieve a file just use:

Copy-Item -FromSession $session -Path c:\results.txt -Destination .
If you liked this post, please share!

1 comment:

  1. This is way coooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooool


Related Posts Plugin for WordPress, Blogger...