Example: set an advanced parameter value in VMware via vSphere PowerCLI

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, March 20, 2016

Follow me on Twitter as @mattiasgeniar

If you manage any kind of VMware environment, chances are you’ve heard of the vSphere PowerCLI. It’s a Windows PowerShell extension that offers direct management of your hypervisors, VMs or configuration through a powerful CLI interface.

It’s a VMware automators’ wet dream.

I’ll completely ignore the installation part of PowerCLI and dive right into an example. Here’s how to connect to a vCenter Server and set an advanced parameter on a particular VM.

$ Connect-Viserver -Server your.vcenter.server.tld -User your_username -Password your_password

Name Port User
---- ---- ----
your.vcenter.server.tld 443 your_username

This output means you’re connected (and authenticated) to your vCenter. The next commands in your shell will now be sent to that connection.

$ get-vm YOUR-VM-NAME | New-AdvancedSetting -Name snapshot.asyncConsolidate.forceSync -Value TRUE -confirm:$False

The above will find the VM named YOUR-VM-NAME and set the advanced parameter snapshot.asyncConsolidate.forceSync to the value TRUE, without asking for an explicit confirmation.

This way, you can set almost any kind of VMX parameter without shutting down the VM first.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.