A quick lesson on Powershell and Get-AdvancedSetting

A quick lesson on Powershell and Get-AdvancedSetting

I had a need to understand the powershell command “Get-AdvancedSetting” which is a vmware powercli command to pull the advanced settings of any VMware entity. This was also an exercise in powershell and helping me understand the handling of output. I didn’t find the official documentation very helpful which only had the below command as a reference.

Get-AdvancedSetting -Entity Server -Name '*smtp*'

The blog Pragmatic IO by Brett Sinclair had a walk through to suppress the shell warning on esxi hosts which helped me better understand what I was trying to get at. Below is what I pulled out from his walkthrough.

Get-vmhost | where {$_.Version -eq "6.5.0"} | Get-AdvancedSetting -Name UserVars.SuppressShellWarning | sort-object Entity | ft Entity, Value -Autosize

Here we have the full command. Below I’ll break down each part.

Get-vmhost

This gets all esxi hosts in the vcenters you’re connected to.

here

Allows you to filter the hosts to only apply settings to ones you want. Currently this is filtering out all hosts with version 6.5 but could be changed to any other option for our needs.

Get-AdvancedSettings

Pulls settings from the advanced page, in this case the value of the Shell Warning suppression.

Sort-Object

Does exactly what it sounds like, it sorts the out put using the entity which in this case is the host names.

ft

FT is an alias for Format-Table and this does is determine how the output is formatted and displayed. We could also potentially out-grid view or Export-CSV depending on what we want to accomplish.  Here we only want the Host name and Value of the advanced setting.

 

We could then potentially pipe it into Set-AdvancedSetting if we wanted to change the value.

set-advancedsetting -value %value%

Creating a quick and easy way to change advanced settings across and entire cluster, vcenter, or multiple vcenters helps to quickly resolve problems freeing up time for other issues.

 

Thanks for reading.

Comments are closed.
%d bloggers like this: