Using PowerShell to mount virtual hard disks in Windows Server “8”

Yesterday I showed you how easy it is to mount virtual hard disks with Windows Explorer in Windows Server “8”.  But what if you want to script it? Don’t worry, we have you covered.

First – we have the very simple Mount-VHD command that allows you to mount a virtual hard disk.  But we can do better than that!  One of the most common questions about scripting virtual hard disk mount is: “How do I find out the drive letter that has been assigned to the virtual hard disk?”.

Well, you can do this in Windows Server “8” by running: Mount-VHD <VHD name> –passthru | Get-Disk | Get-Partition | Get-Volume

Which will give you something like this: