Tuesday, May 31, 2016

Error Using PowerShell Direct

If you've not heard of it, PowerShell Direct is a nifty new way that you can connect with virtual machines on a Windows 10 or Windows Server 2016 Hyper-V host. PowerShell Direct lets you enter PowerShell remoting sessions or invoke commands on a VM from the Hyper-V without requiring network connectivity.

To enter a PowerShell remoting session:
Enter-PSSession -VMName NameOfVM
I've played with this a bit before and it's pretty cool. I've never had any issues with it. However, today when working with some VMs provided for a course I'm working on I got longer version of this error when trying to connect:
Enter-PSSession : An error has occurred which Windows PowerShell cannot handle. A remote session might have ended.
+ FullyQualifiedErrorId :  CreateRemoteRunspaceForVMFailed,Microsoft.PowerShell.Commands.EnterPSSessionCommand
This same error message is provided if your authentication credentials fail. So, I reset the local administrator password on the VM, but no fix.

This was a generation 1 VM given to me. So, my first throught is that maybe its the generation of VM. Nope. I tested with other generation 1 and generation 2 VMs and all worked fine.

What it finally ended up being was the version of VM. The VM was built on a Windows Server 2012 R2 host. So, it was version 5 rather than version 7.1 for the VMs that I had created.

To view the version:
Get-VM | FT Name,Version
To update the version:
Update-VMVersion NameOfVM
After updating the VM to from version 5 to version 7.1 PowerShell Direct worked just like it is supposed to. This is worth noting because none of the articles about PowerShell Direct mention the version as a required.


  1. But I just realised..the Host and the VMs must have the latest PS version installed otherwise, there is going to be issues connecting to the vms. For instance, if the Host has PS v.5 and the VM has PS 4. the connection with enter-newPSsession wont work.

    1. I think PowerShell Direct is limited to just Windows 10 and Windows Server 2016 VMs (which come with PS v5. I don't think upgrading down versions like Win 2012 R2 to PSv5 v5 will allow PowerShell Direct.