PeetersOnline.nl
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:
$OM.QueryOptions(‘ADV_OPTION_NAME’)
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.
$OM.UpdateOptions($newOption)
Tadaa!
5 Responses to Setting of advanced options with the VI Toolkit
Tags
Active Directory API bind order cleanup cluster CPU Custom Fields datastores description device management directory tree errors Event Log file name filter Fun function HA IT known issues License Server LUN multipath NIC objects Oneliner portgroups PowerCLI PowerShell profile recursive Registry Scripts security session share snapshots SQL Stat VI Toolkit VMware vSphere WMI WSUS ZenArchives
- July 2012
- July 2011
- February 2011
- January 2011
- December 2010
- May 2010
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008





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!
Strange that I am trying to change vpxSetting:
$SI = Get-View ServiceInstance
$OM = Get-View $SI.Content.Setting
$OM.QueryOptions(“log.level”)
#$newOption = New-Object VMware.Vim.OptionValue
$newOption.Key = “log.level”
$newOption.Value = info
$OM.UpdateOptions($newOption)
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?
Bubba,
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: http://keithhill.spaces.live.com/Blog/cns!5A8D2641E0963A97!6058.entry
hugo,
is it also possible to set advanced settings of a virtual machine ?
this would be really handy, i cannot find it
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)