Increase Windows drives with PowerCLI and PowerShell

For a while I have thought about trying to automate one of the most annoying things I have to do, which is extend the drives of my Windows servers when they start to run out of space. Performing this task manually makes me want to punch my life. As most Windows guys know, doing this via GUI is not difficult, but its manual and takes a few minutes. Manual is bad. Automation good.

In my research I found a few articles that sort of automate this process, although it became clear that trying to match a VMware VM disk with a Windows disk is an absolute pain in the ass with PowerCLI. That part is likely necessary if I want to fully automate this task. For my environment, it wasn’t worth the hassle. So I decided to build a PowerShell function to increase the drive of a Windows VM, although I do manually select what disks you wanted to resize for both the VMware virtual machine and the Windows server. Yes, I did use Read-Host for this (ducks from collective community attempted slap to face) in order to prompt for which disks to resize.

I also ensured -Confirm:$True is set for the resizing commands as an extra safety measure. After all, I dont want to accidentally extend a drive by 1TB when I meant 1 GB. Also keep in mind, this requires Windows 8+/Server 2012+ as it uses PowerShell storage module commands.

So, to run this I just use Add-VMDiskSpace -VM Test-1 -IncreaseSpaceGB 5, answer a few questions and be done with it. The end result if that my C drive is 5 GB larger. Yay!

2 Responses to “Increase Windows drives with PowerCLI and PowerShell

  • Lars Panzerbjørn
    13 hours ago

    Hi,

    Thanks for the scripts, just an observation; You use “$IncreaseSpaceGB” in your parameter set, but “$IncreaseSpace” in the script…

    Cheerio,
    Lars

Leave a Reply

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