I Love PowerCLI!

I had a requirement to add an additional virtual hard disk to 50 virtual machines. This was going to be a painful job through the vSphere Client so I resorted to PowerCLI.

The virtual machines all had a name starting PerfTest with a number at the end from 1 through to 50, e.g. PerfTest1, PerfTest2, ….., PerfTest50. The new virtual hard disks all needed to be created on a datastore separate to the virtual machine, named XIV_PERFTEST_NOREP and each of them needed to be 8GB.

I was able to create and add all of these new virtual hard disk with a single line of PowerCLI

For ($i=1;$i le 50;i++) {New-HardDisk –VM PerfTest$i –CapacityGB 8 –Datastore XIV_PERFTEST_NOREP}

This entry was posted in PowerCLI, Powershell, VMware. Bookmark the permalink.

Leave a Reply

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