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! :)


Tagged with:

5 Responses to Setting of advanced options with the VI Toolkit

  1. bubba says:

    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. bubba says:

    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. admin says:

    That has something to do with “expression mode” versus “command mode”. In this case, it is not able to guess that you meant to provide a string. It tried to find a commandlet or executable that matches the name info. To be safe, you can always use parenthesis. Or read more about parsing modes here:!5A8D2641E0963A97!6058.entry

  4. bjorn bats says:


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

  5. Sai Garimella says:

    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