Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Home  » Operations Manager  » Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet

Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 3:50 AM :: Rank: 33
Author
Points: 7670
Level: System Center Specialist

I am trying to retrieve overrides with the SCOM Command Shell. I can get the values I want, (timeadded, value, parameter), but what I cannot find is the rule or monitor it applies to. So I started playing around with the Command Shell and discovered that the documentation for Get-Override is complete rubbish!

So I tried to get the properties of an override using 

get-override | where {$_.Name -match '<overridename'>}

When I do this, it prompts me for the management pack it's contained in. How can I find what parameters are required when get-help -detailed shows none of them???

 

   Report Abuse
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 4:16 AM :: Rank: 68
Author
Points: 30700
Level: System Center Expert

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

   Report Abuse
RE: Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 7:46 AM :: Rank: 43
Author
Points: 72684
Level: System Center Expert

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!

   Report Abuse
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 10:25 AM :: Rank: 39
Author
Points: 7670
Level: System Center Specialist

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?

   Report Abuse
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 10:44 AM :: Rank: 37
Author
Points: 30700
Level: System Center Expert
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"
   Report Abuse
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 11:32 AM :: Rank: 28
Author
Points: 47503
Level: System Center Expert
Tom, were you talking about getting Pete's one-liner or Daniele's larger script to a single file?
   Report Abuse
RE: Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Fri, Aug 20, 2010 2:05 PM :: Rank: 44
Author
Points: 7670
Level: System Center Specialist

 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.

   Report Abuse
RE: Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Sat, Aug 21, 2010 3:51 AM :: Rank: 28
Author
Points: 1183
Level: System Center Specialist

Thanks for calling me "great", dude... I am embarassed now :-)

   Report Abuse
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Sat, Aug 21, 2010 4:04 AM :: Rank: 35
Author
Points: 1183
Level: System Center Specialist
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... :-)
   Report Abuse
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Sat, Aug 21, 2010 9:17 AM :: Rank: 33
Author
Points: 30700
Level: System Center Expert
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?
   Report Abuse
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Sat, Aug 21, 2010 12:43 PM :: Rank: 36
Author
Points: 7670
Level: System Center Specialist
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
   Report Abuse
RE: Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Sun, Aug 22, 2010 4:33 PM :: Rank: 34
Author
Points: 72684
Level: System Center Expert

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.

   Report Abuse
Re: Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Posted: Mon, Aug 23, 2010 5:50 AM :: Rank: 23
Author
Points: 7670
Level: System Center Specialist
This works beautifully. Cheers Daniele, Andreas and Pete!
   Report Abuse

Home  » Operations Manager  » Need to retrieve undocumented parameters for a SCOM PowerShell cmdlet
Top Contributors
Featured Members
Pete Zerger
Points: 72684
Level: System Center Expert
Tommy Gunn
Points: 47503
Level: System Center Expert
Simon Skinner
Points: 40804
Level: System Center Expert
Andreas Zuckerhut
Points: 30700
Level: System Center Expert
Stefan Koell
Points: 30179
Level: System Center Expert