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
#
# Laura.Park@microsoft.com
# July 5, 2017
New-SCOMManagementGroupConnection -ComputerName MyManagementServer.contoso.com $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
Comments
- Anonymous
July 28, 2017
Laura - This is exactly what I can use. When I run the script, I am able to get hits for the DisplayName and Description. However, I get no matches for the Criteria. I am thinking the GUID is being returned and utilized in the 2nd IF statement, thus no match.