Overall SCCM Component Status

This page is to show all the SCCM component status.

# SCCM Component Status
# Rui Qiu
# 9/3/2021


# Module import and variables set up
Import-Module dbatools
$sqlserver = 'XXX'
$database = 'XXX'
$siteserver = 'XXX'
$sitecode = 'XXX'
$tallyinterval = '0001128000100008'

# Setting up SQL Query
$Query = "
Select 
    MachineName,
    ComponentName,
	Case
		when Status = 0 then 'OK'
		when Status = 1 then 'Warning'
		when Status = 2 then 'Critical'	
	End as 'Status',
	Case
		when State = 0 then 'Stopped'
		when State = 1 then 'Started'
		when State = 2 then 'Paused'
		when State = 3 then 'Installing'
		when State = 4 then 'Re-installing'
		when State = 5 then 'De-installing'
	End as 'State',
	Infos,
	Warnings,
	Errors
from vSMS_ComponentSummarizer
where TallyInterval = N'$TallyInterval'
and SiteCode = '$SiteCode '
Order by Status,ComponentName
"

# Run SQL Query
$data = Invoke-DbaQuery -SqlInstance $sqlserver -Database $database -Query $query | ForEach-Object {
    @{ 
        MachineName = $_.MachineName 
        ComponentName = $_.ComponentName
        Status = $_.Status
        Infos = $_.Infos
        Warnings = $_.Warnings
        Errors = $_.Errors
    }
}

# Setting up the table columns
$Columns = @(    
    New-UDTableColumn -Property MachineName -Title Server
    New-UDTableColumn -Property ComponentName -Title Component 
    New-UDTableColumn -Property Status -Title Status 
    New-UDTableColumn -Property Infos -Title Infos 
    New-UDTableColumn -Property Warnings -Title Warnings 
	New-UDTableColumn -Property Errors -Title Errors
)

# Create a table to show the data
New-UDTable -Data $data -Columns $Columns -ShowSort  -Title 'SCCM Component Status' -ShowSearch -Dense -Export

Leave a Comment