Setting of advanced options with the VI Toolkit

It’s a bit tricky to find, but the API reference showed me where to look. And now I’m posting it here, so you don’t have to search any further.

First, connect to the Option Manager:
$SI = Get-View $ServiceInstance
$OM = Get-View $SI.Content.Setting

Query current values of advanced options:

To change or add an advanced option:

Create a new object to hold the new settings.
$newOption = New-Object VMware.Vim.OptionValue

Set the Key and Value you would like to add or change.
$newOption.Key = ‘ADV_OPTION_NAME’
$newOption.Value = 300

Use the UpdateOptions method to execute the change.

Tadaa! :)