Monday, October 31, 2016

Expand a VHD/VHDX with Powershell

In the spirit of the "GUI-less" future that Microsoft and other vendors are pushing, I recently removed the GUI from all of our Hyper-V hosts. Now, I know I'm a bit late to the party on this one. I've been cleaning up a lot of things left over from past generations of IT guys, and removing the GUI from our Hyper-V and SOFS hosts just happened to be one of those things.

Last night we received an alert from OpsMan about one of our VMM servers running low on drive space. I figured, "no problem, I'll just pop into Hyper-V Manager and expand the disk". To my dismay, I quickly remembered that I had removed the GUI. "How the heck am I going to expand that disk???", I quietly said to myself.

In comes Powershell...

Using Powershell I was able to expand the disk within seconds! The cmdlet is simple, you just need to know the path to the VHD/VHDX.

Example:

Resize-VHD -Path \\SOFS01\virtualHardDisk.vhdx -SizeBytes 80GB

Then boot the server, open Disk Management, and extend the volume.

No comments:

Post a Comment