Since Windows PowerShell version 5, Microsoft has implemented a new way to directly manage your virtual machines without network connectivity. PowerShell Direct has been introduced in Windows Server 2016 and Windows 10 version. it allows you to create a remoting session without any network connectivity from:
- Windows 10 Hyper-V host
- or Windows Server 2016 Hyper-V host
to
- Windows 10 virtual machine
- or Windows Server 2016 virtual machine
Basically, this is the same syntax as a PowerShell session, with the only difference that the -VMName parameter is used instead of –ComputerName parameter. Below is an example:
PS > Enter-PSSession -VMName VM01
Or you can use the ID of the VM
PS > Enter-PSSession –VMId 31d787fe-02cd-4363-b50b-16bc8243fc77
This method allows you to log on to the VM and thus run several commands without network connectivity. Of course, you need to be logged on to the Hyper-V host that hosts the virtual machine that you want to manage!
Now, I disable the network adapter and try to log on the VM without PowerShell Direct, I get an error message:
More information about the Hyper-V architecture here: Hyper-V Architecture
Thanks for reading! You can follow me on Twitter @PrigentNico