In Windows Server 2016, Hyper-V 2016, Microsoft has created PowerShell Direct. PowerShell Direct allows us Hyper-V administrators to communicate with a VM from the Hyper-V host regardless of the network configuration, firewall settings, security policies, and/or remote management settings. Provided the VM meets the basic criteria (see below), we can communicate with the VM with simple PowerShell! (Sweet)
*Yes, you could always log in to the VM as well…….<lame>*
PowerShell Direct Requirements:
In order to make use of PowerShell Direct, the following conditions need to be met:
- Hypervisor must be either Windows 10, or Windows Server 2016
- Virtual Machine must be either Windows 10, or Windows Server 2016
- Must have valid user credentials for the VM
- The VM must reside on the same Hypervisor
- The admin logged into the Hypervisor must be a Hyper-V administrator
Example:
In my example, my Hypervisor is Windows 10, and my guest VM is also a Windows 10 machine. (Sorry too lazy to get my server up =) )
Here are some cmdlets you will need to know:
- Get-VM will provide a list of all the VMs on your Hyper-V host
- Get-VM
- This will establish the connection between you (the host) and the guest VM:
- Enter-PSSession -VMName <VMName>
- If you want to run a block of code, rather than single line:
- Invoke-Command -VMName <VMName> -ScriptBlock { commands }
I got that error as I shutdown the VM too quickly…
As you can see, there was no Network Adapter on my VM. Also in the screenshot above, no information was provided when I queried an IPCONFIG.
Also, I was able to shutdown the VM from my host. 🙂
I hope you’re excited as I am! Cheers!
For more information on Hyper-V 2016 and/or PowerShell Direct, see HERE.