Start a new topic

Powershell script - Windows Os Pie chart.

Another one i want to share with the Live Maps Masses. 


$Result = @()

$Target = 10 #Set target for Rate Gauges

$Max = 0

$Versions = @()

$Versions = Get-SCOMClass -Name Microsoft.Windows.Computer | Get-SCOMClassInstance | Select-Object @{LABEL='Version';EXPRESSION='`[LW.Base.Microsoft.Windows.Server.BaseOS.Category].CategoryName'} | foreach {$_.'Version'.value} | Select-Object -Unique

$UniqueVersions = $Versions.Count

$Computers = Get-SCOMClass -Name Microsoft.Windows.Computer | Get-SCOMClassInstance | Select-Object Id,HealthState,InMaintenanceMode,IsAvailable,@{LABEL='Server';EXPRESSION='`[Microsoft.Windows.Computer].PrincipalName'},@{LABEL='Version';EXPRESSION='`[LW.Base.Microsoft.Windows.Server.BaseOS.Category].CategoryName'}

for ($i=0; $i -lt $UniqueVersions; $i++)

{

                $versionCount = 0

                Foreach ($computer in $Computers) {

                                If ($computer.'Version'.value -eq $Versions[$i]) {

                                                $versionCount++

                                }

                }

                $TempValue = New-Object System.Object

                $TempValue | Add-Member -type NoteProperty -name Title -Value $Versions[$i]

                $TempValue | Add-Member -type NoteProperty -name Value -Value $versionCount

                $Result += $TempValue

}

$Result

Login or Signup to post a comment