|
|
Re: SCOM Command Shell Automation Query Issue
Posted: Sat, Jun 20, 2009 7:49 AM :: Rank: 1 |
Author
|
|
|
Points: 2967
Level: System Center Specialist |
Thank you for your rating!
|
Looks like $class needs to be set to a value first.
|
|
Reply
Report Abuse
| Your Reports Help Protect the Community |
|
The community depends on each member to help keep Answers a safe and positive place. Do your part by using the form below to report Q&A that violates the Community Guidelines.
|
Additional Detail(optional)
|
|
Report AbuseCancel
|
|
|
|
|
Re: SCOM Command Shell Automation Query Issue
Posted: Sat, Jun 20, 2009 10:33 AM :: Rank: 0 |
Author
|
|
|
Points: 21237
Level: System Center Expert |
Thank you for your rating!
|
Thanks Brian, you may be right. The article where I retreived this snippet implies it should work as is, but frankly the Powershell he's doing casting from string is a bit over my head. I may have to go to ground and build from scratch.
|
|
Reply
Report Abuse
| Your Reports Help Protect the Community |
|
The community depends on each member to help keep Answers a safe and positive place. Do your part by using the form below to report Q&A that violates the Community Guidelines.
|
Additional Detail(optional)
|
|
Report AbuseCancel
|
|
|
|
|
Re: SCOM Command Shell Automation Query Issue
Posted: Sun, Jun 21, 2009 5:35 AM :: Rank: 1 |
Author
|
|
|
Points: 762
Level: System Center Hero |
Thank you for your rating!
|
I posted a comment on Jonathan's blog linking here to let him know that snippet is buggy...
|
|
Reply
Report Abuse
| Your Reports Help Protect the Community |
|
The community depends on each member to help keep Answers a safe and positive place. Do your part by using the form below to report Q&A that violates the Community Guidelines.
|
Additional Detail(optional)
|
|
Report AbuseCancel
|
|
|
|
|
Re: SCOM Command Shell Automation Query Issue
Posted: Sun, Jun 21, 2009 8:10 AM :: Rank: 1 |
Author
|
|
|
Points: 70
Level: System Center Enthusiast |
Thank you for your rating!
|
I've lost access to all of my VMs. The key here may also be this part:
foeach($targetId...
A variable is declared, but not used later.
In addition, as already mentioned, $class isn't defined either.
|
|
Reply
Report Abuse
| Your Reports Help Protect the Community |
|
The community depends on each member to help keep Answers a safe and positive place. Do your part by using the form below to report Q&A that violates the Community Guidelines.
|
Additional Detail(optional)
|
|
Report AbuseCancel
|
|
|
|
|
Re: SCOM Command Shell Automation Query Issue
Posted: Sun, Jun 21, 2009 11:59 AM :: Rank: 6 |
Author
|
|
|
Points: 30
Level: System Center Enthusiast |
Thank you for your rating!
|
I'm not sure what I was thinking when I posted that. Must have been a late night? I posted the working scipt a few minutes ago.
Thanks for catching this!
-Jonathan
foreach ($targetId in get-task | where {$_.displayname -match "task_name"} | foreach-object {$_.get_target().id.tostring()}) {get-monitoringclass | where {$_.id -eq $targetId} | select displayname}
|
|
Reply
Report Abuse
| Your Reports Help Protect the Community |
|
The community depends on each member to help keep Answers a safe and positive place. Do your part by using the form below to report Q&A that violates the Community Guidelines.
|
Additional Detail(optional)
|
|
Report AbuseCancel
|
|
|
|
|
Re: SCOM Command Shell Automation Query Issue
Posted: Mon, Jun 22, 2009 6:36 AM :: Rank: 0 |
Author
|
|
|
Points: 21237
Level: System Center Expert |
Thank you for your rating!
|
This Powershell snippet returns the target of the task perfectly! This is truly not even what I wanted the snippet for, but your example is valuable in exposing how to cast the data type for a script I need to put together for some batch processing. I'll post my results to my blog here when finished.
Thank you all for your assistance!
|
|
Reply
Report Abuse
| Your Reports Help Protect the Community |
|
The community depends on each member to help keep Answers a safe and positive place. Do your part by using the form below to report Q&A that violates the Community Guidelines.
|
Additional Detail(optional)
|
|
Report AbuseCancel
|
|
|