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.
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
That doesn't really meet my needs as I have multiple vCenters I want to be able to run the script against.
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.
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