I’ve had VMware’s PowerCLI installed on my admin PC for months now, but I hadn’t had a chance to use it until today. But I’m glad I did!
On several previous occasions I’ve needed to use the vSphere CLI (f/k/a RCLI) or the Perl SDK for specific tasks, but did not find them… intuitive. Sure, maybe if I had all the VMware commands and shell scripts memorized, but who has time for that?
Anyway, this morning I realized I had provisioned several new VM guests without selecting the Customization Specifications… so I had new Windows clones with no SYSPREP. Yes, I realize I could’ve blown them away and started afresh… but again I say: who has time for that? A couple minutes of Googling revealed a forum thread which mentioned the exact commands I needed.
So, for posterity’s sake, here are the simple steps you can take to apply the customization after the VM has been cloned or built from template:
- Login to our vCenter:
- List all the Customization Specs available:
Get-OSCustomizationSpec | fl Name
- Ensure that the target VM is currently powered down:
Get-VM [VM_NAME] | Shutdown-VMGuest
- Apply the spec:
Get-VM [VM_NAME] | Set-VM -OSCustomizationSpec [SPEC_NAME] -Confirm:$true
That’s it! A few moments later I could see the event for the “Customize virtual machine guest OS” task completed, then I powered up the VM and SYSPREP ran like it should.
Of course, VMware has provided online reference and downloadable PDFs, but you may never need them. The PowerCLI supports all the ease of online help and command, object, and property discovery that PowerShell typically offers, so you can get started fast. When you open the console, PowerCLI helpfully reminds you to login with
Connect-VIServer, list VMs with
Get-VM, and get a list of all 258 cmdlets with
I hope that’s enough to get you started. Drop me a note on Twitter or leave a comment below if you find this kind of post helpful. Happy virtualizing!