Bagikan melalui


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:\data.bar -Destination C:\

This is very handy, and you can read more about this here: https://msdn.microsoft.com/en-us/virtualization/hyperv_on_windows/user_guide/vmsession

Cheers,
Ben

Comments

  • Anonymous
    May 26, 2016
    Great stuff!
  • Anonymous
    May 27, 2016
    This makes me very happy - I raised this on Microsoft Connect (back in those heady days).
  • Anonymous
    May 28, 2016
    nice posting, thanks