Working with PowerShell Direct

PowerShell Direct is a new feature provided by the next release of Windows Server that enables to run PowerShell commands from Hyper-V hosts in a virtual machine. It works without the network and so without WinRM or other features. This is great when a firewall is misconfigured or when a network issue occurs and avoids you to manage your server. In this topic I’ll configure the network configuration on a Nano Server that is not reachable.

I have deployed a Nano Server from the Technical Preview 3. In this version, network information can be displayed as below.

Before PowerShell direct, we ran Enter-PSSession cmdlet with ComputerName parameter to execute commands on a remote server. On the below screenshot, I’m connecting to my Nano Server called Nano01 (IP: Note that credentials are required to open a remote PowerShell session.

Next I modify the address IP of Nano01 to make it unreachable from the network.

I run a ping and as you can see below, Nano01 is unreachable.

To finish I open the Nano01 console to verify the “bad” address IP.

Without PowerShell direct, it would be really difficult to regain control on your Nano Server because there is no shell even if you plug a screen on your server. But fortunately, we have PowerShell Direct.

PowerShell Direct

In the next release of Windows Server, the Enter-PSSession cmdlet has a new parameter called VMName. So from your Hyper-V host you can run Enter-PSSession -VMName <VM Name> -Credential Get-Credential (you can also replace -VMName parameter by -VMGuid and specify the VM Guid). On the below screenshot, you can see that I’m connected to Nano01 with PowerShell direct. Note that credentials are also mandatory to open a remote PowerShell session though PowerShell Direct.

Then I run again a netsh command to change the IP Address of Nano01.

The Invoke-Command cmdlet has also the VMName parameter to run script blocks through PowerShell direct (VMGuid parameter is also available). In the below screenshot I used Invoke-Command cmdlet to change the DNS Server of Nano01.

I try again a ping to verify if I can connect to Nano01. Oh yeah it’s working J.

About Romain Serre

Romain Serre works in Lyon as a Senior Consultant. He is focused on Microsoft Technology, especially on Hyper-V, System Center, Storage, networking and Cloud OS technology as Microsoft Azure or Azure Stack. He is a MVP and he is certified Microsoft Certified Solution Expert (MCSE Server Infrastructure & Private Cloud), on Hyper-V and on Microsoft Azure (Implementing a Microsoft Azure Solution).


  1. Really Great post! can i use it in 2012? i will check it! thanks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Check Also

Deploy Hyper-V from USB stick with unattended file

When you have few Hyper-V hosts and when you have not the System Center products, ...

Specialize Windows Server Hyper-V guest OS automatically

If you have not SC Virtual Machine Manager, you have no access to VM Template ...

How to deploy a converged network with Windows Server 2016

If you read the news regularly, you probably have heard something about converged network. This ...