|
|
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 4:16 AM :: Rank: 56 |
Author
|
|
|
Points: 27764
Level: System Center Expert |
Thank you for your rating!
|
Hi,
you can always pipe a | get-member to get the properties and functions of an object, however this is not always a complete list.
So, if you run something like:
$MP = get-managementpack -name "My.MP"
$override = ($MP | get-override)[0]
$override | get-member
You get a bunch of properties and functions.
In your case, you want to find an Override's target, which differs from the different override types. If it's a monitor Override there's a Monitor property but the value is ManagementPackElementReference.
$override.Monitor
Won't show you much, but the Reference has a function called GetElement()
$override.Monitor.GetElement()
This outputs the monitor.
The target of an Override is configured in Context (Class like Windows Computer) and Context Instance (Class Instance like your.machine.in.your.domain.com). Context is also only a ManagementPackElementReference but with GetElement() you'll get it as well.
$override.Context.GetElement()
Contextinstance is a GUID I think, can't verify that now though.
But, it's not undocumented, you can either import the SDK assemblies and check them out with the Object Browser of Visual Studio or you can download the SDK docs from MIcrosoft: http://www.microsoft.com/downloads/details.aspx?FamilyID=a16bd9c0-55a4-4a65-ba7f-f876158be0c3&displaylang=en
|
|
| 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 Abuse |
|
|
|
RE: Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 7:46 AM :: Rank: 38 |
Author
|
|
|
Points: 65652
Level: System Center Expert |
Thank you for your rating!
|
Tenchuu amazes as always I see . I couldn't help but notice you're working with overrides. There is a completely awesome script I had totally forgotten about.
I wrote a simple one-liner but didn't sort out traversing the relationship between override and the rule, monitor or override it was associated with.
Command Shell: Dumping all overrides in Operations Manager 2007 (the Pete one-liner version.
On the other hand, the great Daniele Muscetta [MSFT] posted a script here on SCC that picks up where I left off. Here's a link to his script, which goes the distance to present overrides in a meaningful way.
Command Shell: Dumping all overrides in Operations Manager 2007 (Script)
Good luck!
|
|
| 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 Abuse |
|
|
|
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 10:25 AM :: Rank: 34 |
Author
|
|
|
Points: 6581
Level: System Center Specialist |
Thank you for your rating!
|
Thank you both, this is very close to what I was attempting to craft on my own. However, I do wish the inventory script would output everything to one file instead of many. Any chance you can suggest how to append those csv files into a single spreadsheet?
|
|
| 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 Abuse |
|
|
|
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 10:44 AM :: Rank: 32 |
Author
|
|
|
Points: 27764
Level: System Center Expert |
Thank you for your rating!
|
Just remove the filter, like this:
get-ManagementPack | get-Override |sort-object LastModified -descending | select-object name, displayname, xmltag, value, timeadded, lastmodified | export-Csv -Path "c:\overrides.csv"
|
|
| 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 Abuse |
|
|
|
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 11:32 AM :: Rank: 25 |
Author
|
|
|
Points: 42868
Level: System Center Expert |
Thank you for your rating!
|
Tom, were you talking about getting Pete's one-liner or Daniele's larger script to a single file?
|
|
| 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 Abuse |
|
|
|
RE: Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 2:05 PM :: Rank: 40 |
Author
|
|
|
Points: 6581
Level: System Center Specialist |
Thank you for your rating!
|
I was looking at Daniele's large script. He is using export-csv to multiple files, but when I try to send these to a single file, I can't make it work. It seems export-csv doesn't support -append in v1, unless I am missing something. I am just struggling to find a way to get the output into a single file.
|
|
| 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 Abuse |
|
|
|
RE: Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Sat, Aug 21, 2010 3:51 AM :: Rank: 24 |
Author
|
|
|
Points: 1183
Level: System Center Specialist |
Thank you for your rating!
|
Thanks for calling me "great", dude... I am embarassed now :-)
|
|
| 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 Abuse |
|
|
|
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Sat, Aug 21, 2010 4:04 AM :: Rank: 31 |
Author
|
|
|
Points: 1183
Level: System Center Specialist |
Thank you for your rating!
|
Export-Csv does not support -append, AFAIK.
Even if there are some good scripts on the web that implement it, such ast this: http://dmitrysotnikov.wordpress.com/2010/01/19/export-csv-append/
but this is also for Powershell v2.
Hint: it might be time to UPGRADE to powershell v2 - OpsMgr cmdlets work just fine with it and all existing scripts should just work (mine do, anyway...).
There is also a good discussion about this type of scripting topic here
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e38b802f-ca1f-44aa-8b75-3ab2d6650c35
Essentially, the solution given there would be not to stream each set of overrides to the CSV file for each MP, but hold them in a collection of objects and keep appending to that.... and then streaming to CSV the whole lot, at the end. You can add a property to those objects with the MP name, since that would not be in each file name anymore...
this is more or a pure powershell question than a system center question, anyhow... :-)
|
|
| 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 Abuse |
|
|
|
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Sat, Aug 21, 2010 9:17 AM :: Rank: 31 |
Author
|
|
|
Points: 27764
Level: System Center Expert |
Thank you for your rating!
|
Erm, why is that such a big deal now anyway? You can just get all Overrides at once and export them to a csv file, why would you need to append to an existing file all of a sudden?
|
|
| 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 Abuse |
|
|
|
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Sat, Aug 21, 2010 12:43 PM :: Rank: 31 |
Author
|
|
|
Points: 6581
Level: System Center Specialist |
Thank you for your rating!
|
Good question Tenchuu. If you look at Daniele's script, it is the first I have seen that includes the display name of the rule or monitor that the override applies to. I need this info in a single spreadsheet for tracking purposes for our operations team (it is the format they requested). Daniele's script does everything except putting them into a single file
|
|
| 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 Abuse |
|
|
|
RE: Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Sun, Aug 22, 2010 4:33 PM :: Rank: 24 |
Author
|
|
|
Points: 65652
Level: System Center Expert |
Thank you for your rating!
|
Tom, I agree that this script would be even better if the output were redirected to a single file and with a bit of additional formatting. Since I actually need this script tomorrow morning, and Daniele did all the hard work for us already (thanks Daniele!), what you and I need is a quick change. Here are the changes I made to his script.
- Added logic to store the output of all the packs in a single variable
- Added the -notypeinfo flag to rid the output of the type info line on each pass, which is garbage for our purposes
- Added an extra column to include the name of the management pack the override is stored in
- Moved the override name to the far right column. The name string is so long and unruly it clutters the report
If you look at the code, you'll basically see I am simply passing the output of the inner foreach loop to a variable outside the loop so we can store it up for output to a single csv file.
Not perfect, but should meet the need here. I have attached a copy of the updated script. Login to the site and download from my post. I'll put it to the Downloads section tomorrow.
|
|
| 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 Abuse |
|
|
|
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Mon, Aug 23, 2010 5:50 AM :: Rank: 19 |
Author
|
|
|
Points: 6581
Level: System Center Specialist |
Thank you for your rating!
|
This works beautifully. Cheers Daniele, Andreas and Pete!
|
|
| 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 Abuse |
|