More vSphere HealthCheck Remediation scripts
More vSphere HealthCheck Remediation scripts
If you follow this blog you’ll know that I like to keep track of useful snippets and scripts that can be used to fix any issues flagged during environment health checks. You can find other healthcheck remediation scripts to Disconnected connected CDs, Set DCUI and ESXi Shell interactive timeouts and configure VM isolation settings here. Scripts on how to detect thick or thin layouts for VMDKs can be found here.
So in the vCommunity spirit of sharing!
Disable SSH on Host
Occasionally we need SSH to be running on hosts, but as best practice this should be stopped when not needed. The below one-liner can be adapted to disable SSH on singular hosts, clusters or across an entire SDDC as needed.
Get-VMHost | Foreach {Stop-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} )}
Guest OS and VMtools reporting mismatch
It often comes up on health checks that the OS installed inside a VM doesn’t match the configured OS. This could be important if you are using the reported OS as a tag against which backup or firewall rule policies are being applied. For example an NSX firewall rule could use this field as a tag to stop any ingress or egress SMB traffic to Windows XP VMs. Pretty powerful, but not if it’s not being properly detected.
This can’t be simply changed whilst the VM is online. The below one-line script reports on the various fields where this data is stored and presents back a table to help identification.
Get-VM | Sort | get-view -property @("Name", "guest.GuestFamily", "guest.GuestFullName", "config.GuestFullName") | Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}}, @{N="VM Tools Guest Family" ;E={$_.guest.GuestFamily}}, @{N="VM Tools Running OS" ;E={$_.Guest.GuestFullName}} | Format-Table -AutoSize
There we are two very simple one line healthcheck remediation scripts.
Thanks
Simon