Displaying a list of ESXi Hosts and their Syslog Configurations

One of my customers recently found that their ESXi hosts were not uniformly configured for syslog shipping, so asked me to help them audit their environment.  They have hundreds of ESXi hosts, so going through the advanced settings in the GUI for each of their hundreds of hosts didn't seem like the best approach... PowerCLI to the rescue!

In this case, I put together a quick one-liner.  It gets all of the VMHosts, then generates a string in the format of "<ESXi Hostname>,<Configured SysLog Host>".  That string is then parsed by the convertfrom-csv cmdlet, which adds the "VMHost" and "SysLogServer" headers to the line.  That line is then output and the system moves on to the next host in the list.  When the command is completed, the system has generated a nice table with a "VMHost" column that is populated by ESXi hostnames and a "SysLogServer" column that is populated with their configured Syslog servers.

Importantly though, this output is an array of PowerShell objects with the "VMHost" and "SysLogServer" parameters, so I was able to easily pass that to where to find all VMHosts that did not conform to the desired configuration.

Here's the line to generate the full table:

get-vmhost | % {"$($_.name),$(($_ | get-VMHostSysLogServer).host)" | convertfrom-csv -header VMHost,SysLogServer}

And here's the line with the "where" filtering in place:

get-vmhost | % {"$($_.name),$(($_ | get-VMHostSysLogServer).host)" | convertfrom-csv -header VMHost,SysLogServer} | ? {$_.SysLogServer -notlike "<Desired Configuration>"}


Popular posts from this blog

Deleting Orphaned (AKA Zombie) VMDK Files

Clone a Standard vSwitch from one ESXi Host to Another

Orphaned VMDK Files