VMware Cloud Community
shaka
Enthusiast
Enthusiast

VM Guest OS reporting

Hi I am trying to write a script to report the number of different types of guest operating systems I have running in my vCenter. But can't figure out how I group the the similar operating systems and get a count so that I can export it to a report.

0 Kudos
4 Replies
UmeshAhuja
Commander
Commander

Hi ,

Try using free tool RVTools which will give you the overall information across the VMware infrastructure. By this you can get the data exported into excel and  get the count for whatever parameters you want or requested to you .

To download RVTools free version :- RVTools - Home

Thanks n Regards
Umesh Ahuja

If your query resolved then please consider awarding points by correct or helpful marking.
0 Kudos
shaka
Enthusiast
Enthusiast

That doesn't really meet my needs as I have multiple vCenters I want to be able to run the script against.

0 Kudos
Sivaramsharmar
Enthusiast
Enthusiast

Hi Shaka,

You can try like below.

Get-View -ViewType VirtualMachine | select @{N='VM OS';E={$_.Summary.Config.GuestFullName}} | Group-Object "VM OS" | select Name,Count

It will pull the report based on VM Template Which you have chosen while creating a Template.

Anjani_Kumar
Commander
Commander

you can use this as well. this will generate the pivot table of all the guest os in your vcenter environment.

# —- VM Guest OS Pivot Table —-

$VMOSversions = @{ }

$FullVM | % {

  # Prefer to use GuestFullName but try AltGuestName first

  if ($_.Config.AlternateGuestName) { $VMOSversion = $_.Config.AlternateGuestName }

  if ($_.Guest.GuestFullName) { $VMOSversion = $_.Guest.GuestFullName }

  # Seeing if any of these options worked

  if (!($VMOSversion)) {

    # No 'version' so checking for tools

    if (!($_.Guest.ToolsStatus.Value__ )) {

      $VMOSversion = "Unknown – no VMTools"

    } else {

      # Still no 'version', must be old tools

      $toolsversion = $_.Config.Tools.ToolsVersion

      $VMOSversion = "Unknown – tools version $toolsversion"

    }

  }

  $VMOSversions.$VMOSversion++

}

$myCol = @()

foreach ( $gosname in $VMOSversions.Keys | sort) {

  $MyDetails = "" | select OS, Count

  $MyDetails.OS = $gosname

  $MyDetails.Count = $VMOSversions.$gosname

  $myCol += $MyDetails

}

$vVMOSversions = $myCol | sort Count -desc

If (($vVMOSversions | Measure-Object).count -gt 0) {

  $Header = "VMs by Operating System : $($vVMOSversions.count)"

  $vVMOSversions

}

$vVMOSversions = $null

Please consider marking this answer "correct" or "helpful" if you found it useful. Anjani Kumar | VMware vExpert 2014-2015-2016 | Infrastructure Specialist Twitter : @anjaniyadav85 Website : http://www.Vmwareminds.com
0 Kudos