Quantcast
Channel: Operations Manager - General forum
Viewing all articles
Browse latest Browse all 11941

Passing a default parameter to a powershell script

$
0
0

Hello,
I wrote a short PS script that gets the parameters of an alert and writes them to a log file.

The parameters I pass (via a channel) are:

'$Data/Context/DataItem/AlertName$' '$Data[Default='Not Present']/Context/DataItem/ManagedEntityDisplayName$' '$Data[Default='Not Present']/Context/DataItem/LastModifiedBy$' '$Data[Default='Not Present']/Context/DataItem/TimeRaisedLocal$' '$Data[Default='Not Present']/Context/DataItem/LastModifiedLocal$' '$Data[Default='Not Present']/Context/DataItem/AlertDescription$' '$Data[Default='Not Present']/Context/DataItem/ManagedEntityPath$\$Data[Default='Not Present']/Context/DataItem/ManagedEntityDisplayName$' '$Data[Default='Not Present']/Context/DataItem/ResolutionStateName$'

On some alerts the information I get in the log file is correct.

But on others the output looks like this:

Alert Name: Backward Compatibility Script Error, Source: test101, Path: System, Last Modified By: 8/11/2013 10:48:04 AM, Raised Time: 8/11/2013 10:48:04 AM, Modified Time: An error occurred on line 119 while executing script , Description: MOM, Resolution State: Backward.

Looks like there was no data in the  Last Modified By field and instead of passing the default value: Not Present, the info for the next fields shifted left  'Description' and 'Resolution State' fields got junk. 

Does anyone know why wasn't the default field passed and where does the junk coming from?

Thanks

Alex.


Viewing all articles
Browse latest Browse all 11941

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>