Hi Guys,
I am powershell novice so asking for assistance for what is to me a difficult problem but hopefully a quite easy solution to PS experts!!.
I have and existing powershell script (not written by me!!) which is designed to use a passed in Parameter (SCOM Alert ID) to then set additional information in the alert, eg $alert.CustomField1 = $alert.PrincipleName etc etc.
I am looking to add functionality to this script to be able to add additional 'Custom' information which is stored in a separate text/csv file. The text/csv file has header line ServerName,ServiceOwner,Application Tier so a row in the file would be MYSERVER.CONTOSO.COM,Joe Bloggs, Tier 1 - there will be one unique row for each server in our environment (over 600 rows)
So what I need to do is using the passed in alertID I can use $alert.PrincipleName to find the corresponding row in the text file and pull in the additional details stored in field 2 and 3 ie ServiceOwner and ApplicationTier. This logic holds for the majority of alerts but IF server name is a specific value (eg MYSTSERVER.CONTOSO.COM) then instead of using $alert.PrincipleName to match servername in text file, I need to match on another alert property $Alert.MonitoringObjectDisplayName - but the server name in this field is part of a larger string in the format eg: User Services Watcher for Pool [MYTARGETSERVER.CONTOSO.COM] - so I need to extract the severname from between the square brackets of the string to then perform the match with the text file.
Hopefully I have explained what I'm trying to do clearly - if not I'm happy to provide further clarification and can also post up the existing PS Script I'm trying to modify if thats any help.