Search SCOM subscriptions for a specific string

Today I made this simple script for a customer. It searches all notification subscriptions in your SCOM management group for a specific string.

This script will look at subscriptions' display name, description, and criteria. Matched results are printed out in green, and added to an array which is returned at the end of the script.

 # Searches the display name, description, and criteria fields of all SCOM Subscriptions
# July 5, 2017

New-SCOMManagementGroupConnection -ComputerName $searchStr = Read-Host "What are you looking for?" # get all subscriptions $allSub = Get-SCOMNotificationSubscription $resultSub = @() foreach ($sub in $allSub) { if ( ($sub.DisplayName -like "*$searchStr*") -or ($sub.Description -like "*$searchStr*") ) { write-host "Found your string in subscription name or description:`n`t$($sub.DisplayName)`t`t$sub" -ForegroundColor Green $resultSub += $sub continue } if ($sub.Configuration.Criteria -like "*$searchStr*") { write-host "Found your string in subscription criteria:`n`t$($sub.DisplayName)`t`t$sub" -ForegroundColor Green $resultSub += $sub } } $resultSub