Copy to mounted VHD with PowerShell for automated Hyper-V Provisioning – Part II

While I initially tried to get the Powershell Mount-VHD cmdlet working – I gave up as it didn’t seem to exist (despite obvious documentation:

I was using a Server 2012 DS for testing purposes, but as I was just working on the drive letter side of things – I had yet to install the Hyper-V role. Turns out that Mount-VHD is exactly what I need to get the driveletter of a VHD and requires Hyper-V to be installed. The last example on the Microsoft Site gives you all you need to know:

With a little modification we can ensure that the System Reserved partition does not get in the way:

This is what you will get after mounting using the above command:


You can then select the driveletter column to get what you need:

Much more simple than my previous attempt!


1 Comment

  1. I use this pipeline for mount and determinate drive letter. But sometimes this doesn’t work. Looks like system not always can mount drive or mounting is very long process and get-partition is very quick process, so that pipeline order is violated. I don’t know why. But if I try run this pipeline again, then it is work well.

    Does pipeline work fine for you?

Leave a Reply

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

© 2020 Chris's Blog

Theme by Anders NorénUp ↑