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