I am trying to set the CimoemProvideEnabled value for all the hosts in a VC.
This works:
Get-VMHost myhost | Set-VMHostAdvancedConfiguration -Name UserVars.CIMoemProviderEnabled -Value ([System.Int32] 1 )
This does not :
$esxhosts
= Get-vmhost
foreach
($esxhost in $esxhosts)
{
Set-VMHostAdvancedConfiguration
-VMHost $_ -Name UserVars.CIMoemProviderEnabled -Value ([System.Int32] 1)
}
The error message is :
Set-VMHostAdvancedConfiguration : Cannot validate argument on parameter 'VMHost'. The argumen
t is null or empty.
Where is the error? Thanks
$esxhosts = Get-vmhost
foreach ($esxhost in $esxhosts)
{
Set-VMHostAdvancedConfiguration -VMHost $esxhost -Name UserVars.CIMoemProviderEnabled -Value ([System.Int32] 1)
}
Or
Get-vmhost | foreach {
Set-VMHostAdvancedConfiguration -VMHost $_ -Name UserVars.CIMoemProviderEnabled -Value ([System.Int32] 1)
}
$esxhosts = Get-vmhost
foreach ($esxhost in $esxhosts)
{
Set-VMHostAdvancedConfiguration -VMHost $esxhost -Name UserVars.CIMoemProviderEnabled -Value ([System.Int32] 1)
}
Or
Get-vmhost | foreach {
Set-VMHostAdvancedConfiguration -VMHost $_ -Name UserVars.CIMoemProviderEnabled -Value ([System.Int32] 1)
}
You have to replace $_ with $esxhost.
Regards, Robert