vSphere virtual machine checks

I’ve recently posted a series of vSphere checks based on PowerCLI. The following couple of checks apply to virtual machines.

The following check looks for virtual machines where the ‘toolsUpgradePolicy’ is set to manual. I like to change this value to ‘upgradeAtPowerCycle’ which causes virtual machines (which are already running tools) to check for an update tools automatically at reboot.
[cc lang=”Powershell”]
Get-View -ViewType VirtualMachine -Property Name, “Config.Tools.toolsUpgradePolicy”,”Guest.ToolsVersionStatus” -Filter @{“Config.Tools.toolsUpgradePolicy”=”manual”} |
Select Name, @{N=”Tools Status”;E={$_.Guest.ToolsVersionStatus}},@{N=”Upgrade Policy”;E={$_.Config.Tools.toolsUpgradePolicy}} |
Sort Name

The following check is one that has caused some discussion with my peers. I can’t find a specific KB article that references this issue, but rumor has it that a Windows virtual machine on a port group with 10GbE uplinks requires a minimum of 1GB of RAM to provide heap space for the network card driver in the guest. To keep this script simple, it simply checks for the fastest link speed uplink on a host, and if greater than 10,000 verifies that all of the virtual machines have at least 1GB of RAM. Since this is rumor I can’t prove that the issue exists — or only exists for Windows guests — all virtual machines on hosts that have 10Gbps uplinks appear on this report. If you have any proof on this issue, or just want to throw in your two cents, please feel free to leave a comment.
[cc lang=”powershell”]
$vmLessThan1GB = @()
Get-View -ViewType HostSystem -Property Name, “Config.Network.Pnic” | %{
$thisHost = $_
$thisHostMaxSpeed = ($_.config.network.pnic | Select @{Name=”SpeedMB”; Exp={ $_.LinkSpeed.SpeedMb } } | sort SpeedMB -Descending | Select -First 1).SpeedMB
if ($thisHostMaxSpeed -ge 10000) {

$vmLessThan1GB += Get-View -ViewType virtualmachine -Property Name, “Config.Hardware.MemoryMB”, “Runtime.Host.Value” -Filter @{“Runtime.Host”=”^$($thisHost.MoRef.Value)$”} |
?{$_.Config.Hardware.MemoryMB -lt 1024} |
Select Name, @{N=”VM RAM (MB)”;E={$_.Config.Hardware.MemoryMB}}, @{N=”VM Host Name”;E={$thisHost.Name}}, @{N=”Max NIC Speed”;E={$thisHostMaxSpeed}}
$vmLessThan1GB | Sort Name

This entry was posted in Scripting, Virtualization. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


Notify me of followup comments via e-mail. You can also subscribe without commenting.