We recently had a customer that we onboarded for a managed service. Part of this service is that we monitor the OS and it turned out there were a LOT of VMs that had very little free disk space left. Now this seemed like a perfect opportunity to apply some automation using PowerCLI.

I grew tired of stringing together cmdlets to achieve the desired result so I decided to write a small powershell function. I exported the disk space alerts from our monitoring system in such a format that I can use this as input to extend the disks. All of the alerts were related to C: drives so I was a bit lazy and just assumed that the C: drive resides on the first disk. Also I don’t bother checking for snapshots. The Set-HardDisk cmdlet will raise an error if a snapshot is present.

Leave a Reply

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