TLDRCustomer wanted to see all RDS Host servers in a view with their current total session count.
Decided to use a powershell grid dashboard, and share the script.
Here’s the gist of it: SCOM_RDSH_TotalSession_PoSHWidget.ps1
How ToKeeping it fairly short this time.
Pre-requisites are:
System Center 2012 R2 with UR2 or later Microsoft RDS Management Pack Microsoft Windows Core OS Management Pack Create a dashboardRightclick and create a new view somewhere, make it a Dashboard View Enter Name and Description Select Grid type, and layout Click cog on grid view Select Powershell Grid Widget Set Name and Description Paste your script into the script box Save The Scriptfunction Add-Criteria(){ param ($criteria ,$clause ) if ($criteria -ne $null ) {$criteria += " AND $clause " } else {$criteria = $clause } return ($criteria ) } $rdsClass = Get-SCOMClass -Name "Microsoft.Windows.Server.2012.R2.RemoteDesktopServicesRole.Service.RDSessionHost" $rdsHosts = Get-SCOMMonitoringObject -Class $rdsClass | Sort-Object -Property '[Microsoft.Windows.Computer].PrincipalName' $rdsTotalSessionRule = Get-SCOMRule -Name "Microsoft.Windows.Server.2012.R2.RemoteDesktopServicesRole.Service.RDSessionHost.PerformanceCollection.TotalSessions" $objectName = "Terminal Services" $counterName = "Total Sessions" $InstanceName = "" $i =0 foreach ($rdsHost in $rdsHosts ) { if ($rdsClass -ne $null ) { $criteria = Add-Criteria -criteria $criteria -clause "MonitoringClassId = '{$($rdsClass .Id)}'" } if ($rdsHost -ne $null ) { $criteria = Add-Criteria -criteria $criteria -clause "MonitoringObjectFullName = '$($rdsHost .FullName)'" } if ($objectName -ne $null ) { $criteria = Add-Criteria -criteria $criteria -clause "ObjectName = '$objectName '" } if ($counterName -ne $null ) { $criteria = Add-Criteria -criteria $criteria -clause "CounterName = '$counterName '" } $perfReader = (Get-SCOMManagementGroup).GetMonitoringPerformanceDataReader($criteria ) while ($perfReader .Read()) { $perfData = $perfReader .GetMonitoringPerformanceData() $perfValueReader = $perfData .GetValueReader(((Get-Date ).AddMinutes(-180 )),(Get-Date )) $perfValues = @() while ($perfValueReader .Read()) { $perfValues += $perfValueReader .GetMonitoringPerformanceDataValue() } $perfValue = $perfValues | Sort-Object -Property TimeSampled | select -Last 1 $dataObject = $ScriptContext .CreateInstance("xsd://stegenfeldt/nullschema" ) $dataObject = $ScriptContext .CreateFromObject($rdsHost , "Id=Id,Health=HealthState,Host=Path" , $null ) $dataObject ["Time Sampled" ] = $perfValue .TimeSampled $dataObject ["Total Sessions" ] = $perfValue .SampleValue $ScriptContext .ReturnCollection.Add($dataObject ) } $criteria = $null ++$i }