header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

We have a new sponsor!  Introducting Pragma Systems.  See the home page for details.

SCOM get-monitor syntax problem
Last Post 23 Apr 2009 09:12 PM by r0nwilliams. 6 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
ScottMossUser is Offline
New Member
New Member
Posts:3
Avatar

--
17 Apr 2009 04:49 PM  

Normal usage of the get-monitor cmdlet uses the following syntax:

get-monitor -criteria 'Id = ''7da5b2dd-1d7a-0d63-f2be-3091b22fc726'''

I'm trying to use this cmdlet in a loop passing info from $alerts to feed the cmdlet but i've run into a syntax problem that I dont know how to get around. If I use

get-monitor -criteria 'Id = ''$alert.MonitoringRuleId'''

I get the following error which I kind of expeceted to get Get-Monitor : Id='$alert.MonitoringRuleId' -- Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx).Id='$alert.MonitoringRuleId' -- Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

How do I pass info in a loop to this cmdlet?
Any thoughts on this would be great!
Thank you!

Scott Moss
ScottMossUser is Offline
New Member
New Member
Posts:3
Avatar

--
17 Apr 2009 07:07 PM  
If I try and use this in the script

get-monitor -criteria Id = $alert.MonitoringRuleId

I get the following error:
Get-Monitor : A parameter cannot be found that matches parameter name 'd5b2959a-9ff7-6e12-30ff-94e0a8933c12'.
Scott Moss
halr9000User is Offline
PowerShell MVP, Site Admin
Advanced Member
Advanced Member
Posts:527
Avatar

--
17 Apr 2009 07:40 PM  
Put parens around it. Using quotes forced it to be a strong which caused the casting error. Using parens will change the order of execution such that accessing the property will happen before the cmdlet execution

Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast
Author, TechProsaic
r0nwilliamsUser is Offline
New Member
New Member
Posts:3
Avatar

--
23 Apr 2009 07:43 PM  
I am having a similar issue with GET-ALERT using the -criteria . I am trying to pass in an argument and cant get it to work due to the single strong quotes. I have tried using parenthese and double quotes but cant figure it out. How can we get CRITERIA to work without single strong quotes:


I am actually tring to use Id as a crtiteria, even though my example below shows ResolutionState.

I want to run it as a script in the following format, for example
Get-AlertScript.ps1 D7463D6E-F334-40C3-3A86-C68A77D36BF8

THIS WORKS
get-alert -criteria 'ResolutionState = ''0'''


THIS DOESNT
get-alert -criteria 'ResolutionState = ''$args'''

you can email me at ron d0t williams at catapultsystems d0t c0m
ScottMossUser is Offline
New Member
New Member
Posts:3
Avatar

--
23 Apr 2009 08:14 PM  
this is what got mine working.
get-monitor -criteria "Id = '$($alert.MonitoringRuleId)'"
pay attention to where the ' and the " goes.
Scott Moss
r0nwilliamsUser is Offline
New Member
New Member
Posts:3
Avatar

--
23 Apr 2009 08:42 PM  

That worked!!! Thanks!

using:    get-alert -criteria "Id = '$($args)'"

r0nwilliamsUser is Offline
New Member
New Member
Posts:3
Avatar

--
23 Apr 2009 09:12 PM  
Scott, i plugged you on my blog :-)
http://www.r0nwilliams.com/
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 footer
footer