header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
SCOM get-monitor syntax problem
Last Post 23 Apr 2009 12:12 PM by r0nwilliams. 6 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Scott MossUser is Offline
New Member
New Member
Posts:3
Avatar

--
17 Apr 2009 07:49 AM

    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
    Scott MossUser is Offline
    New Member
    New Member
    Posts:3
    Avatar

    --
    17 Apr 2009 10:07 AM
    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:565
    Avatar

    --
    17 Apr 2009 10:40 AM
    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 10:43 AM
    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
    Scott MossUser is Offline
    New Member
    New Member
    Posts:3
    Avatar

    --
    23 Apr 2009 11:14 AM
    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 11:42 AM

    That worked!!! Thanks!

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

    r0nwilliamsUser is Offline
    New Member
    New Member
    Posts:3
    Avatar

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


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