PowerCLI: UserVars.CIMoemProviderEnabled, changing to a value of 1 (or 0)

Summary:
This value appears after installing the Dell OMSA vib for ESXi 4.1.  Tried changing this value to 1 using PowerCLI proved a bit more difficult than I originally thought, even cheating w/ Onyx.
Example:
Using this:
$changedValue = New-Object VMware.Vim.OptionValue[] (1)
$changedValue[0] = New-Object VMware.Vim.OptionValue
$changedValue[0].key = "UserVars.CIMoemProviderEnabled"
$changedValue[0].value = 1
$_this = Get-View -Id 'OptionManager-EsxHostAdvSettings-00000'
$_this.UpdateOptions($changedValue)
I’d get this ‘useful’ error:
Exception calling "UpdateOptions" with "1" argument(s): "A specified parameter was not correct.
"
At line:1 char:21
+ $_this.UpdateOptions <<<< ($changedValue)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException


Solution:
Apparently the ‘value’ property needs to be declared as an int64 type.  By default, Powershell assumes the value to be a ‘string’ type.  Below is what will work:
$changedValue = New-Object VMware.Vim.OptionValue[] (1)
$changedValue[0] = New-Object VMware.Vim.OptionValue
$changedValue[0].key = "UserVars.CIMoemProviderEnabled"
[int64]$changedValue[0].value = 1
$_this = Get-View -Id 'OptionManager-EsxHostAdvSettings-00000'
$_this.UpdateOptions($changedValue)

To determine what type of value the 'option' is looking for, you can query it to find out, like so:
($_this.setting | where {$_.key -eq "UserVars.CIMoemProviderEnabled"}).value.gettype().name


Above will return the 'type' of 'value' this particular setting is looking for.

Side Note:
How would you determine host and that obscure ‘OptionManager-ESXHostAdvSettings-0000’ object to work with and what host that references?  Here is how you can get to that object in the simplest fashion:
$MyESXHost = Get-VMHost MyESXHost
$MyESXHost.ExtensionData.ConfigManager.AdvancedOption
# Using examples from above, it can also be wrote out like this:
$changedValue = New-Object VMware.Vim.OptionValue[] (1)
$changedValue[0] = New-Object VMWare.Vim.OptionValue
$changedValue[0].key = "UserVars.CIMoemProviderEnabled"
[int64]$changedValue[0].value = 1
 
$_this = Get-View -ID $MyESXHost.ExtensionData.ConfigManager.AdvancedOption
$_this.UpdateOptions($changedValue)

Comments

Michael Ryom said…
Thanks just saved me a lot of time troubleshooting! :)

Popular posts from this blog

NSX-T: Release associated invalid node ID from certificate

NSX-T: vCenter and NSX-T Inventory out of Sync (Hosts in vSphere not showing up in NSX-T)

Azure VMware Solution: NSX-T Active/Active T0 Edges...but