Many admins use Host Profiles, vCM, vCOPS and the like to ensure element compliance within their VI inventory. While these can be fine solutions, many companies do not have the luxury of owning these products.
In many cases the targeted use of powerCLI commands across your environment can help to keep things in ‘check’ and help you keep on top of some types of config drift.
An example of this could be when you deploy some new hosts into an existing environment and you’d like to ensure they have some Advanced Settings Parameters configured, a common one being to suppress the Cluster warnings when Local &/or Remote Tech Support is enabled (SSH).
Everyone has seen it;
Note:Access to the Advanced Parameters used to be made using the ‘get-vmhostadvancedconfiguration’ command, which was deprecated as of 5.1R1. Now the “Get-AdvancedSetting” cmd-let should be used.
In this example, I’m going to query all hosts where the version is 5.5, and return the current value for the UserVars.SuppressShellWarning parameter.
1 |
Get-Vmhost |where {$_.Version -eq "5.5.0"} | Get-AdvancedSetting -Name UserVars.SuppressShellWarning |
(this is also sorted by hostname)
To refine the output, let’s filter out superflous data and only include the hostname and the actual parameter value whilst also justifying the table output;
1 |
Get-Vmhost |where {$_.Version -eq "5.5.0"} | Get-AdvancedSetting -Name UserVars.SuppressShellWarning | sort-object Entity | ft Entity, Value -Autosize |
As you can see the 2 x hosts I just added do not have the ShellWarnings suppressed (as shown by the 0 value), so let’s fix that;
1 |
Get-Vmhost |where {$_.Version -eq "5.5.0"} | Get-AdvancedSetting -Name UserVars.SuppressShellWarning |Set-AdvancedSetting -Value 1 |
Done ! , but just to prove it, repeat the query to check;
1 |
Get-Vmhost |where {$_.Version -eq "5.5.0"} | Get-AdvancedSetting -Name UserVars.SuppressShellWarning | sort-object Entity | ft Entity, Value -Autosize |
Looks good.
Another example would be to ensure all hosts have VAAI support on. (why would you ever have it off on compliant Arrays !? but it can happen)
1 2 3 4 5 |
Get-Vmhost |where {$_.Version -eq "5.5.0"} | Get-AdvancedSetting -Name DataMover.HardwareAcceleratedMove | sort-object Entity | ft Entity, Value -Autosize Get-Vmhost |where {$_.Version -eq "5.5.0"} | Get-AdvancedSetting -Name DataMover.HardwareAcceleratedInit | sort-object Entity | ft Entity, Value -Autosize Get-Vmhost |where {$_.Version -eq "5.5.0"} | Get-AdvancedSetting -Name VMFS3.HardwareAcceleratedLocking | sort-object Entity | ft Entity, Value -Autosize |
There are numerous other settings that this can be useful for, such as;
Scratch Drive Location [ScratchConfig.ConfiguredScratchLocation]; Central/Global Syslog server [Syslog.global.logHost]’
But, in general, change Advanced settings after careful consideration, particularly if you are trying to ‘tune’ performance. Ordinarily this is NOT required, can break things and may lead to other problems.
Of course, if you make changes, make them part of your build documentation.
2 thoughts on “PowerCLI for basic vCenter/ESXi config management”