Copy files over PowerShell Direct (and more)

We recently updated a number of the capabilities of PowerShell Direct.  In Windows 10 Insider builds greater than 14280, and in Windows Server 2016, you can now create persistent PowerShell sessions using PowerShell Direct.

The format for doing this is:

$PSSession = New-PSSession -VMName <VMName> -Credential (Get-Credential)

You can then use this session for a bunch of more advanced activities.  One that I have been using a lot lately “Copy-Item” to move files in and out of virtual machines.  You can do this by running:

Copy-Item -ToSession $PSSession -Path C:\ -Destination C:\

This is very handy, and you can read more about this here: