Home > PowerCLI, VMware, vSphere > Find VMs with Mismatched OS using PowerCLI

Find VMs with Mismatched OS using PowerCLI

Almost every environment has one or more VMs where the running OS doesn’t match what is configured on the VM.


Let me explain:

Every VM has a property which contains the OS version:


This is usually set when you create the VM.  In this example, the VM is set to Windows 7 x64.  But if you install an OS in the VM, VMware is also aware of the Guest OS through VMware Tools.  This is visible on the Summary page of the VM.


Both fields should match, but if you upgrade the OS inside the VM and forget to change the Settings of the VM, you have a mismatch.

The following piece of PowerCLI code will generate a list of VMs with a mismatched OS.

Get-View -ViewType "VirtualMachine" -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") |`
Where-Object {($_.Config.GuestFullName -ne $_.Guest.GuestFullName) -and `
($_.Guest.GuestFullName -ne $null)} | `
Select-Object -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}}, `
@{N="Running OS";E={$_.Guest.GuestFullName}} | `
Format-Table -AutoSize



Categories: PowerCLI, VMware, vSphere
  1. Guest
    July 27, 2011 at 11:55

    Might also be worth reading Frank Denneman’s post as to why this could be an issue:


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: