Monthly Archive



Hyper-V book

The Month of Lunches Hyper-V book I was working on was cancelled by the publisher.

The good news is that it’s most likely going to be resurrected with another publisher and will hopefully be available later this year.

More to follow when the details are finalised

PowerShell v6 and PowerShell Direct

Not seen this reported anywhere so thought I post.


PowerShell v6 went to GA in January 2018. PowerShell Direct is a feature of Windows 10/Windows Server 2016. By accident I found that PowerShell v6 and PowerShell Direct work together.


PowerShell v6 is based on .NET core which is basically a subset of the full .NET CLR (that powers Windows PowerShell )


PowerShell Direct is a technology by which a PowerShell v5.1 session on a Windows 10/Windows Server 2016 Hyper-V host can establish a remoting session to a Windows 10/Windows Server 2016 virtual machine over the VM bus rather than using WSMAN.


By default PowerShell v6 can’t access the Hyper-V module but if you add the PowerShell v5.1 module path to the PowerShell v6 module path:

$env:PSModulePath = 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\;' + $env:PSModulePath


You can then create a credential

$cred = Get-Credential manticore\richard


This is required because you’re not relying on Kerberos to authenticate as you do in standard remoting within the domain.

You can then create your session:

$s = New-PSSession -VMName W10PRV01 -Credential $cred


And use it

Invoke-Command -Session $s -ScriptBlock {Get-Service}


The session has a ComputerType of VirtualMachine

PS> $s | fl

ComputerType : VirtualMachine
ComputerName : W10PRV01
ContainerId :
VMName : W10PRV01
VMId : 374d0569-3b22-441d-84dc-802aed67dea9
ConfigurationName :
InstanceId : c6e6b1c1-8ed5-409f-be4c-0a1262342cb7
Id : 1
Name : WinRM1
Availability : Available
ApplicationPrivateData : {DebugMode, DebugStop, UnhandledBreakpointMode, PSVersionTable...}
Runspace : System.Management.Automation.RemoteRunspace
State : Opened
IdleTimeout : -1
OutputBufferingMode :
DisconnectedOn :
ExpiresOn :


You can also enter the session

PS> Enter-PSSession $s
[W10PRV01]: PS C:\Users\Richard.MANTICORE\Documents>


I’ve not tried all the Hyper-V cmdlets but the Get* cmdlets that I have tried all work.

Hyper-V VM start time

Its fairly easy to see how long a VM has been running – but how do you know the Hyper-V VM start time?

In Hyper-V the VM uptime is easy to find

PS> Get-VM | where State -eq 'Running'

Name       State   CPUUsage(%) MemoryAssigned(M) Uptime           Status             Version 
 ----       -----   ----------- ----------------- ------           ------             ------- 
 W16AS01    Running 6           1246              00:12:18.6480000 Operating normally 8.0 
 W16CN01    Running 0           538               00:09:18.2180000 Operating normally 8.2 
 W16DC01    Running 0           940               00:15:19.1550000 Operating normally 8.0 
 W17035CN01 Running 0           540               00:06:17.7980000 Operating normally 8.2 
 W1709CN01  Running 0           512               00:03:15.8540000 Operating normally 8.2


Sometimes you might want to know when the VM was started

The Uptime property is a TimeSpan so you can calculate the start time

PS> $now = Get-Date 
PS> Get-VM | where State -eq 'Running' | select Name, @{N='StartTime'; E={$now - $_.Uptime}}

Name       StartTime 
 ----       --------- 
 W16AS01    02/12/2017 10:23:15 
 W16CN01    02/12/2017 10:26:16 
 W16DC01    02/12/2017 10:20:15 
 W17035CN01 02/12/2017 10:29:16 
 W1709CN01  02/12/2017 10:32:18


Once you’ve added the calculated property you can use like any other property

PS> Get-VM | where State -eq 'Running' | select Name, @{N='StartTime'; E={$now - $_.Uptime}} | sort StartTime

Name       StartTime 
----       --------- 
 W16DC01    02/12/2017 10:18:46 
 W16AS01    02/12/2017 10:21:47 
 W16CN01    02/12/2017 10:24:47 
 W17035CN01 02/12/2017 10:27:48 
 W1709CN01  02/12/2017 10:30:50


Using calculated fields like this is a handy technique for changing the way data is displayed.

Deal of the Day – 15 June 2017

My book is Manning’s Deal of the Day  - 15 June 2017:

Half off Learn Hyper-V in a Month of Lunches. Use code dotd061517au at

Sign up for DoD notifications at

PowerShell Direct failure

PowerShell Direct is introduced with Server 2016/Windows 10. it enables you to create a remoting session from the Hyper-V host to a VM using the VM name or ID. I recent discovered a PowerShell Direct failure that I couldn’t explain until now.

Normally you do this:

PS> New-PSSession -VMName w16cn01 -Credential (Get-Credential w16cn01\administrator)

Id Name    ComputerName  ComputerType  State  ConfigurationName  Availability
-- ----     ------------  ------------    -----  -----------------  ------------
1 Session1       W16CN01  VirtualMachine  Opened                       Available

But on one particular machine I was getting this

PS> New-PSSession -VMName w16as01 -Credential (Get-Credential w16as01\administrator)
New-PSSession : [W16AS01] An error has occurred which Windows PowerShell cannot handle. A remote session might have ended.
At line:1 char:1
+ New-PSSession -VMName w16as01 -Credential (Get-Credential w16as01\adm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
+ FullyQualifiedErrorId : PSSessionOpenFailed

I couldn’t find an explanation for this particular PowerShell Direct failure

I’ve been working with PowerShell v6 and OpenSSH the last few days and I noticed that the PowerShell directory had been removed from the system path by the installation of one of these pieces of software.

W16AS01 had been the first machine I experimented with PowerShell v6/OpenSSH and it was the first to experience this PowerShell direct failure.

I checked W16AS01 and sure enough the PowerShell folder was missing from the system path. Adding the Powershell folder back onto the path (and restarting the machine for luck) then retrying PowerShell Direct gives:

PS> New-PSSession -VMName W16AS01 -Credential (Get-Credential W16AS01\Administrator)

Id Name            ComputerName    ComputerType    State         ConfigurationName     Availability
-- ----            ------------    ------------    -----         -----------------     ------------
1 Session1        W16AS01         VirtualMachine  Opened                                 Available

Looks like I’ve found a solution for this particular PowerShell direct failure

Hyper-V book deal

March 11 2017 – My book Learn Hyper-V in a Month of Lunches is Manning’s Deal of the day. Get 50% off using code dotd031117au at

Also see

Using Hyper-V

When you think of using Hyper-V most people think of virtualising their infrastructure – big servers running 10s, 100s or even 1000s of virtual machines.


There is another reason for using Hyper-V


You can use Hyper-V to create a VM so you can install an application that may conflict with you standard workstation – as an example you may need access to a component of an older version of Office for instance Infopath 2010 but you don’t want that application to conflict with your installation of the latest and greatest version of Office.


The Windows client operating system has the ability to install Hyper-V since Windows 8. So if you’re running Windows 8, Windows 8.1 or Windows 10 AND your machine is capable of supporting Hyper-V:

- Windows Enterprise, Professional or Educational

- 64-bit processor with SLAT

- CPU support for VM monitor mode extension

- Minimum of 4GB of memory


Install Hyper-V

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V –All


Create a virtual switch and create your VMs


See and subsequent links


Better still get a copy of Learn Hyper-V in a Month of Lunches

Learn Hyper-V – Deal of the day – January 28 2017

Deal of the Day January 28: Half off my book Learn Hyper-V in a Month of Lunches. Use code dotd012817au at


More information from DOTD's page at

Christmas treat

If you’re looking for something to treat yourself for Christmas then garb a copy of My new book – Learn Hyper-V in a Month of Lunches.


Better still tomorrow 18 December 2016 you can get the book for half price:


Deal of the Day December 18: Half off Learn Hyper-V in a Month of Lunches. Use code dotd121816au at

Hyper-V book

I’ve been working with Andy Syrewicze on Learn Hyper-V in a Month of Lunches.


Its now available in Manning’s Early Access program (MEAP)


Until 14 November 2016 you can get the MEAP for half price using code mlsyrewicze