FAQ, PowerShell, SCOM, System Center

10 Useful SCOM PowerShell Scripts

System Center Operations Manager (SCOM) comes with a good PowerShell module, there are many occasions where you want something done quick and easy.

There are a total of 183 different PowerShell cmdlets in the SCOM 1807 PowerShell module, that already speaks for itself how much you can do with this PowerShell module!

This blog post will provide an example for most commands, if you do not see the examples clearly, it’s suggested you open the GIF in another browser tab.

Note: Some of the SCOM PowerShell cmdlets below are not found in the Microsoft documentation page for the System Center PowerShell 2016, these scripts have been tested to work with the following SCOM versions: 2016, 1801 and 1807.




Exporting sealed management packs

Get-SCOMManagementPack | where {$_.Sealed -eq $True } | Export-SCOMManagementpack -Path "C:\Management Packs\Sealed"


Exporting unsealed management packs

Get-SCOMManagementPack | where {$_.Sealed -eq $False} | Export-SCOMManagementpack -Path "C:\Management Packs\Unsealed"


Setting a windows computer into maintenance mode

$Agent = "yourcomputer.domain.com"
$Time = (Get-Date).addMinutes(60)
$Instance = (Get-SCOMClass -DisplayName "Windows Computer" | Get-SCOMClassInstance | ? { $_.DisplayName -eq $Agent} )
Start-SCOMMaintenanceMode -Instance $Instance -EndTime $Time -Comment "Maintenance Mode started!" -Reason "PlannedOther"


Retrieve the maintenance mode history for a windows computer

Get-SCOMMaintenanceMode -Instance (Get-SCOMClassInstance -Class (Get-SCOMClass -Name "Microsoft.Windows.Computer") | 
Where-Object {$_.DisplayName -match "Your Computer Name"}) -History -ErrorAction 0



Enable the proxy for all SCOM agents

Get-SCOMAgent | where {$_.ProxyingEnabled -match "False"} | Enable-SCOMAgentProxy


Retrieve all SCOM agents that are grayed out or unavailable

$Agent = Get-SCClass -Name "Microsoft.SystemCenter.Agent"
$GrayAgents = Get-SCOMMonitoringObject -class:$Agent | where {$_.IsAvailable –eq $False}


Retrieve all the SCOM alerts within the last day (highest priority first)

$Date = (Get-Date).AddDays(-1)
(Get-SCOMAlert -Criteria 'ResolutionState = "0"' | Where-Object {$_.LastModified -gt $Date }) | Sort-Object Priority -Descending

Resolution States
0 = New
255 = Closed

Severity Values for Alerts
0 = Informational
1 = Warning
2 = Critical


Retrieve all the subscriptions that a specific subscriber belongs to

Get-SCOMNotificationSubscription | ForEach {
 $Subscriber = $_.DisplayName
 $_.ToRecipients | foreach { 
  If ($_.Name -Like "*Enter Name Here*") {
   Write-Host $Subscriber



Export all the SCOM agents to a CSV

Get-SCOMAgent | Select DisplayName, ManagementGroup, Version, ProxyingEnabled | Export-Csv -NoType C:\SCOMAgents.csv



Retrieve the amount of agents reporting to a SCOM Management / Gateway Server

$MgmtServer = Get-SCOMManagementServer | where { $_.DisplayName -eq "yourSCOMmanagementserver.domain.com"
$TotalAgents = (Get-SCOMAgent -ManagementServer $MgmtServer).count


Note: If you need to retrieve the amount of agents that are reporting to a SCOM Gateway server, change the DisplayName to the SCOM Gateway server name (without FQDN).

553 total views, 12 views today

1 thought on “10 Useful SCOM PowerShell Scripts”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.