locked
Pipe Get-NotificationSubscription to Get-MonitoringClass RRS feed

  • General discussion

  • I'd like to pipe the output of Get-NotificationSubscription to Get-MonitoringClass so I can get the class displayname.

    If I do the following I can see the MonitoringclassIDs.

    Get-NotificationSubscription | where {$_.DisplayName -eq "MOSS_2007"} | foreach-object {$_.Configuration}

    Then I can do

       Get-MonitoringClass -id b4fba47e-3ed1-6288-be9c-dfc8b164ea37|fl displayName

    to get the displayname.

    What I haven't been able to do is pipe the first command to the second.  I haven't been able to access the MonitoringClassIds in any way.

     

     

    Tuesday, January 25, 2011 4:15 PM

All replies

  • You want to do something like this: (more verbose than I'd like, but effective)

    Get-NotificationSubscription |?{ $_.DisplayName –eq ‘MOSS_2007’ } |%{ $_.Configuration.MonitoringClassIds } |%{ Get-MonitoringClass –id $_ }

    or split into a couple of lines to increase readability:

    $ns = Get-NotificationSubscription |?{ $_.DisplayName –eq ‘MOSS_2007’ }

    $ns.Configuration.MonitoringClassIds |%{ Get-MonitoringClass –id $_ }

    Thanks,
    -Lincoln

    Tuesday, January 25, 2011 6:39 PM
  • Excellent, that did the trick, thanks. This will be very useful.

    Though I've been using PWS for a while now I guess there's still plenty to learn as I'm not familiar with the use of ? and % in this context.
    Wednesday, January 26, 2011 1:15 PM