Hyper-V 2016 Cool Feature: PowerShell Direct

PowerShell is a great tool for remotely administering and managing virtual and physical machines. Physical machines do offer the ability of connecting to their DRAC, iLO or Remote KVM to perform actions when there is zero network connectivity. PowerShell Direct gives IT Professionals the ability to run remote PowerShell commands against a guest Hyper-V VM without the IP network requirement. This feature is supported on Hyper-V hosts that are running Windows 10 or Windows Server 2016. The guest VM must also be running Windows 10 or Windows Server 2016 or greater in order to be managed.

PowerShell Direct utilizes the VMBus of the Hyper-V host to communicate with the Guest VM. Traditional PowerShell requires PSRemoting to be enabled and the VMs to have network connectivity. With PowerShell Direct, one could boot up a VM, connect to the VM, configure networking and add to the domain with ease. Microsoft has introduced 2 new variables into PowerShell -VMName and -VMGuid. When connecting to the VMs, first log into the Hyper-V host or Windows 10 desktop. It is possible to use PSRemoting to connect to the parent host and within the PSRemote session then enter PowerShell Direct.



Enter-PSSession is an interactive session to the remote VM. Through this method, your connection remains sticky until you Exit the PowerShell session or close the PowerShell window.




Another method to execute commands within a remote VM is Invoke-Command. Invoke-Command uses PowerShell Direct and is the preferred connection method if executing an entire script. Get-Credential is used to store the credentials within the session, this is used when running multiple lines or commands within a single session.




PowerShell Direct is a brand new feature within Windows Server 2016 that allows the Hyper-V host machine to interact with the Guest VMs without any type of network connectivity. One caveat is that if you’re leveraging Shielded VMs, another new feature in Windows Server 2016 – you’re unable to connect to the VM using PowerShell Direct. I’ll cover Shielded VMs in the next blog!

Add a Comment

Your email address will not be published. Required fields are marked *