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! 🙂

5 thoughts on “Setting of advanced options with the VI Toolkit

  1. Strange, I changed info with “info” and all of a sudden it started working…
    Would you have some more example, but with API Ref, it would really help, thanks!

  2. Strange that I am trying to change vpxSetting:

    $SI = Get-View ServiceInstance
    $OM = Get-View $SI.Content.Setting

    #$newOption = New-Object VMware.Vim.OptionValue
    $newOption.Key = “log.level”
    $newOption.Value = info


    But i get error:

    PS C:Program FilesVMwareInfrastructureVIToolkitForWindows> .queryAdvValue.ps1

    Key Value DynamicType DynamicProperty
    — —– ———– —————
    log.level verbose
    The term ‘info’ is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
    At C:Program FilesVMwareInfrastructureVIToolkitForWindowsqueryAdvValue.ps1:7 char:24
    + $newOption.Value = info <<<<
    Exception calling “UpdateOptions” with “1” argument(s): “A specified parameter was not correct.

    At C:Program FilesVMwareInfrastructureVIToolkitForWindowsqueryAdvValue.ps1:9 char:18
    + $OM.UpdateOptions( <<<< $newOption)

    I am thinking maybe I incorrectly use UpdateOptions?

  3. hugo,

    is it also possible to set advanced settings of a virtual machine ?
    this would be really handy, i cannot find it

  4. Alan – I the script which gets hosts in maint mode is it possible to pull annotations if any for the host – this will be helpful – because annotations caontain why the host was put in maint mode (in our case they are updated manually before putting host in maint mode)

Leave a Reply