Username: Password:
 | Register
Home
System Center Forum
  • News
  • Articles
  • How To Guides
  • Downloads
  • Frequently Asked Questions
  • Links
  • Events
  • Contact Us

Powershell



July 21, 2008



Windows PowerShell in System Center Operations Manager



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Tips -n- Tricks, Training
  Comments: None

Powershell MVP Marco Shaw has written an excellent article on the Command Shell in Operations Manager 2007.  Of particular interest are his review of agent deployment from the Command Shell in SP1, as well as the bulk installation of management packs from the Command Shell.

Read the full article at

http://technet.microsoft.com/en-us/magazine/cc671178.aspx


July 11, 2008



OpsMgr 2007: Exploring discovered inventory with the Command Shell – Groups



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Tips -n- Tricks
  Comments: None

In the previous two posts on the topic, we illustrated first how to export a list of object classes and their descriptions to a spreadsheet for reference, and then we did some exploration into the discovered instances of an existing class.

Related posts

Powershell Tip: Retrieving an inventory of object classes and descriptions from OpsMgr 2007

OpsMgr 2007: Exploring your discovered inventory with the Command Shell

However, you may have noticed that there were groups listed in your spreadsheet of class names and descriptions. And you may have wondered, why is that?

You may be surprised to learn that each group actually represents a unique object class. However, groups represent a special type of class known as singleton class. Singleton classes are used when there is only one instance of a class (as is usually the case with groups). The class is the instance and always exists. For example, there will only ever be one instance of the group called Exchange 2003 Servers in your management group, so it is a singleton class. Because there is only one instance of this class, you never need to write discovery for the class. The single instance of the class is automatically created.

But I digress. What I wanted to illustrate that you can view the membership of a group through the command shell quite easily. For example, to view the members of the ‘SQL 2005 Computers’ group, perform the following steps:

  1. Launch the Operations Manager Command Shell.
  2. Retrieve the Name property of the ‘SQL 2005 Computers’ group from your inventory spreadsheet we created in the previous exercise. (FYI - the name is ‘Microsoft.SQLServer.2005.ComputerGroup’)
  3. Execute the following commands from the Command Shell prompt

cd Microsoft.SQLServer.2005.ComputerGroup

This actually changes our location to the group, just as though it is a folder. Now, to view group members, you can simply enter the following:

Get-childitem

And of course the same formatting and filtering cmdlets we illustrated previously are available, so you can retrieve only the fields you wish in a format that suits your purpose. So a simple example of a prettier version might be

get-childitem | format-table DisplayName

For example, this could be great for retrieve a list of Exchange databases and the server on which they are hosted.

That’s all for now. For great information on how to use the Operations Manager Command Shell, see the recent Live Meeting presentation by Powershell MVP Marco Shaw available for download at the System Center Virtual User Group website.


July 10, 2008



OpsMgr 2007: Exploring your discovered inventory with the Command Shell



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Tips -n- Tricks
  Comments: 1 Comment

In the previous Powershell Tip, you can see that it’s quite easy to enumerate the object classes present in your Operations Manager 2007 environment. You may be surprised to learn it’s equally simple to take this example one step further to enumerate the discovered instances of a given object class.
Using a similar one-liner to the previous tip, we can use get-monitoringclass cmdlet to retrieve a list of the discovered object classes, like so:

get-monitoringclass | select-object DisplayName, Name, Description | export-csv -path c:\classes.csv

We can then find the Name column in this output (not to be confused with DisplayName) to retrieve a list of discovered instances of the object class of our choice by passing output of the get-monitoringclass cmdlet for a single class to the get-monitoringobject cmdlet, as illustrated for the ‘SQL 2005 DB’ object class below:

get-monitoringclass -name “Microsoft.SQLServer.2005.Database” | get-monitoringobject

And using the format-table cmdlet demonstrated in several past examples, we can filter and format results in a neatly organized tabular format, so display only the database DisplayName (e.g. OperationsManager) and PathName, which represents the server and SQL instance that hosts the database.

get-monitoringclass -name “Microsoft.SQLServer.2005.Database” | get-monitoringobject | ft DisplayName, PathName

The resulting output of the PathName is a bit messy, but you can spot the host server and SQL instance name (MSSQLSERVER is the default SQL instance).

DisplayName        PathName
———–                ——–
msdb                         OPSMGR.contoso.com%003bMSSQLSERVER%003amsdb

In the next installment, we’ll take a short look at a special object class…groups


July 9, 2008



Powershell Tip: Retrieving an inventory of object classes and descriptions from OpsMgr 2007



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Tips -n- Tricks
  Comments: 2 Comments

Have you ever wondered what the object classes represent when you’re trying to scope your console view or target a rule or monitor? It  can sometimes be confusing because the description is not included in all areas of the Operations Console. 

 Here’s a short one-liner to retrieve a list of all object classes present in your Operations Manager 2007 management group, including a description of the class:

Get-MonitoringClass | ft DisplayName, Description

Remember, you can send this to a csv file for easy reading in Excel as well.

Get-MonitoringClass | ft DisplayName, Description | export-csv -path c:\classes.csv 

 You can retrieve a list of all cmdlets available in the Command Shell by entering get-operationsmanagercommand.

Update your MOM skills to Operations Manager 2007 at the Operations Manager 2007 Bootcamp! Check the 2008 Bootcamp Schedule and request pricing and availability HERE.


June 24, 2008



Virtual User Group meetings for System Center Enthusiats



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell
  Comments: None

 Today, June 24th 8pm, the 6th online meeting of the Powershell Virtual  User Group, founded by Powershell MVP Marco Shaw. Speakers include Bruce Payette of Microsoft, with topics including Powershell v2 and Managing VMware with Powershell. Good stuff.

Speaker topics:
*Bruce Payette (Microsoft): PowerShell v2 modules.
*Wassim Fayed (Microsoft): PowerShell v2 remoting.
*Hal Rottenberg: Managing VMware Infrastructure using PowerShell.

On, June 26th at noon CDT (1pm New York time), the 1st online meeting of the System Center Virtual User Group takes place, with topics including ACS internals, the new cross-platform feature in OpsMgr 2007 SP2, as well as OpsMgr Powershell tips from MVP Marco Shaw.

  • 12:00PM-12:10PM: Introduction
  • 12:10PM-12:40PM: Anders Bengtsson (OpsMgr MVP) - Cross-PLatform Monitoring in Operations Manager 2007 SP2.
  • 12:40PM-1:10PM: Ryan Brennan (SecureVantage) - ACS Best Practices & Configuration Tips
  • 1:10PM-1:40PM: Marco Shaw (Powershell MVP) - PowerShell within System Center Operations Manager 2007
  • 1.40PM-1:50PM: Closing

June 10, 2008



Powershell Tip: Finding the recipients on all enabled notification subscriptions in OpsMgr 2007



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Tips -n- Tricks
  Comments: None

If you want to very quickly see the list of recipients configured to receive alerts for each of the enabled notification subscriptions in your environment, look no further than the get-notificationsubscription cmdlet in the Operations Manager 2007 Command Shell. Here are a couple  versions of a handy one-liner to dump this information to the console. I like the list version for easy reading on the screen.

Get-NotificationSubscription |where-object {$_.Enabled -eq $true}| Format-List DisplayName, ToRecipients
or
Get-NotificationSubscription |where-object {$_.Enabled -eq $true}| Format-Table DisplayName, ToRecipients

Check out the System Center Solutions Contest now in progress at the System Center Virtual User Group for a chance to win an Xbox 360, Zune 2 or other great prizes.


May 19, 2008



Powershell Tip: Operations Manager 2007 Top Alerts Report - Part 2



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell
  Comments: None

We’d talked a few weeks ago about creating a Top Alerts Report in Powershell to improve upon the Top Alerts Report. So here are variations on that provides an additional elements versus the Top Alerts report (in the Microsoft ODR Report Library) by displaying based on the repeat count and the object for which the alert was logged. When I run the Top Alerts Report, the repeat count seems to be missing in the report logic.After a bit of working with this, I think these meet the need. These should make it easy to determine which computers are logging the most errors and which rules or monitors are the most problematic.

 

Note: All script samples contain | export-csv c:\alerts.csv to export the results to a spreadsheet for easy reading. Just remove this if you want to echo results to the screen.


 
# Most Common Among All Alerts (any resolution state)

get-alert | Sort -desc RepeatCount | select-object -first 10 Name, RepeatCount, MonitoringObjectPath | export-csv c:\alerts.csv

# Most Common Among All Active Alerts

get-alert | where-object {$_.ResolutionState -ne 255 } | Sort -desc RepeatCount | select-object -first 10 Name, RepeatCount, MonitoringObjectPath | export-csv c:\alerts.csv

In this last example, which provides filtering option based on TimeRaised, I had to resort to a two-liner.

# Most Common Among All Active Alerts Raised in Last 7 days

$targetdate = (get-date).AddDays(-7)

get-alert | where-object {($_.ResolutionState -ne 255) -and ($_.TimeRaised -gt $targetdate)} | Sort -desc RepeatCount | select-object -first 10 Name, RepeatCount, MonitoringObjectPath | export-csv c:\alerts.csv

 

Did you find these helpful, or perhaps lacking in some way? I would appreciate your feedback as a comment on this post or via the Contact page.


April 21, 2008



Intelligent tools for Opsmgr Command Shell script development



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell
  Comments: 1 Comment

There are a couple of tools for Powershell scripting that if you try, I don’t think you will ever want to be with out. You pretty frequently hear about PowerGUI, which is a pretty nice tool, especially for Powershell newbies, but I wanted to share with you my favorite toolset I use when working really rolling up my sleeves for some serious work in the shell. I’ll give you some quick tidbits on features, but you really need to give these a trial run.

Powershell Analyzer -  This was the first editor I picked up prior to Powershell 1.0 RTM. You get a SQL Query Analyzer type interface, allowing you to highlight a snippet for code and press F5 to run. What’s more, you get the big white space for scripting with a Powershell window in the upper pane. It has better intellisense than the native shell as well.  I keep a file with all my most common code snippets, such as connecting to my management group. It makes scripting so much more convenient because I can highlight and execute snippets at will.

  • The visual provider explorer lets you visually browse the Powershell drives in an expandable tree view.

  • The vistual results  explorer lets you drag result properties to a toolbar for sorting (much like Silect MP Studio if you’re familiar).

By Powershell Analyzer is just the beginning. You can kick your environment up another notch with Powershell Plus. Powershell Plus turbo-charges your intellisense by indexing all the providers on your machine, and provides advanced intellisense for WMI providers - no need to memorize all those WMI proviers anymore!  The code editor is similar to the white space you see in Powershell Analyzer, but it pops out in a separate floating window. You can save your code snippets in a library for easy retrieval into the editor, and it has a nice debugger.

You really must give these a try. I think I paid about $79 at http://www.powershell.com/analyzer/


April 10, 2008



Powershell Tip: Removing Discovery Data in Operations Manager 2007 SP1



  Posted by: Pete
  Categories: Command Shells, News, Operations Manager 2007, Powershell
  Comments: 2 Comments

Question: What if I do not want to monitor an application or service for a particular server? How can I stop this without overriding every rule and monitor for that server?

Answer: In the RTM release there was no good answer for this all too common situation. Sometimes you may not want to monitor all applications on a computer. However, once the instance of an object-type has been discovered (such as an Active Directory domain controller), rules and monitors are active and running shortly thereafter. In the RTM release of Operations Manager, this meant creating a tremendous number of disable overrides for all rules and monitors to stop unwanted alerts (not fun) or digging into the SDK (also in the ‘not fun’ category).

This was rectified in Service Pack 1 for Operations Manager 2007. In Service Pack 1, the Remove-DisabledMonitoringObject cmdlet was introduced to the Command Shell.

 To remove the discovery data for an object you do not want to monitor, perform the following steps:

  1. Create a disable override for the target computer (or group of computers) for each object discovery you do not wish to run on the target computer. For example, to prevent SQL monitoring on SERVER1, go the Authoring space in the Operations console and create a disable override for each SQL object discovery for SERVER1.
  2. Run Remove-DisabledMonitoringObject with no parameters. This will remove discovery data from the object discoveries for any objects for which you’ve disabled discovery.

 

Unwanted monitoring should cease shortly after execution of these steps.


March 20, 2008



Powershell Tip: Formatting trick to make your search criteria stand out



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Tips -n- Tricks
  Comments: 1 Comment

As I mentioned in a post earlier this week, I really like the many formatting options in Powershell. Here’s another formatting tip not well-documented in my experience. Let’s take this example in which we are looking at whether agent proxy is enabled on my Operations Manager 2007 agents. I want to print all agents and their agent proxy status to the screen, but I want to be able to quickly identify agents where agent proxy is NOT enabled.

This is quite easily done with a foreach loop and the Powershell equivalent of the if-then statement to change the color of the text based on the value of the ProxyEnabled status for each agent. In this case, if ProxyEnabled = false, text output will be RED. If ProxyEnabled = true, text output will be GREEN. I have commented the sample script below to clarify the meaning of each statement.

#Retrieve all agents and assign to a variable
$agents = get-agent

#For each agent in the $agents variable, execute the IF statement
foreach ($agent in $agents){

#If ProxyEnabled = TRUE, write agent Name and ProxyEnabled status to the console in RED.
If ($agent.ProxyingEnabled -match $true) {write-host $agent.name, $agent.proxyingenabled -foregroundcolor “red”}

else

#If ProxyEnabled = FALSE write agent Name and ProxyEnabled status to the console in GREEN.
{write-host $agent.name, $agent.proxyingenabled -foregroundcolor “darkgreen”}
}

Have something you’d like to do with the Command Shell but can’t quite figure out how? Drop me a line via the Contact page.

Update your MOM 2005 skills to Operations Manager 2007 at the Operations Manager Bootcamp! Check the 2008 Bootcamp Schedule and request pricing and availability HERE.


March 18, 2008



Powershell Tip: Operations Manager 2007 Top Alerts Report - Part 1



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Tips -n- Tricks
  Comments: 6 Comments

My favorite characteristic of Command Shell is the availability of the huge array of rich formatting, filtering and sorting options. Oh, and the fact that I can do almost anything in one line. Put these two things together, and we can do some pretty amazing stuff. Watch as we take a MOM 2005 function with it’s own Solution Accelerator (the Alert Tuning SA), complete MOM Reports - and deliver a functional substitute in a single line of Powershell code.

Let’s have a look at the solution and deconstruct what we’re doing. In addition to the obvious get-alert cmdlet, we’re using 4 additional cmdlets together here, each of which has a purpose in filtering, sorting and formatting the output.

I give you, the Operations Manager 2007 Top Alerts Report. Run the following line of code in the Command Shell window:

get-alert | Group-Object Name |Sort -desc Count | select-Object -first 5 Count, Name |Format-Table -auto

And you get output that looks like this:

Here is the role of each cmdlet in the one-liner. If you don’t believe me, remove the cmdlet at the far right, re-run the one-liner  and see the difference in output with each subsequent run.

  • Get-alert - Returns all alerts

  • Group-object - Returns the list with a count of the number of times the alert by a particular name occurs

  • Sort - To sort the list of alerts in descending order by count.

  • Select-Object - Allows us to remove the group column that obscures the display of the full alert name AND allows us to use the -first parameter to return only the top X alerts (top 5 in our example).

  • Format-table - with the -auto flag to left justify and remove the unnecessary space.

 One line of code got us halfway there, but we’re really not done yet. In the next installment, we’ll dig into this output with some more Powershell to further filter our results based on date and time the alerts were raised and drill down to the problem computer(s).


March 4, 2008



Powershell user group webcasts



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Uncategorized
  Comments: None

Marco has made several of his Powershell user group sesssions available online for online viewing.  He’s brought together some great resources, and is a strong supporter of the Operations Manager Command Shell newsgroup.

Sessions available at:

#1: http://marcoshaw.blogspot.com/2007/10/windows-powershell-virtual-user-group.html
#2: http://marcoshaw.blogspot.com/2007/12/windows-powershell-virtual-user-group-2.html
#3: http://marcoshaw.blogspot.com/2008/02/windows-powershell-virtual-user-group-3.html
#4: http://marcoshaw.blogspot.com/2008/02/windows-powershell-virtual-user-group_21.html


March 2, 2008



Update: Checking Operations Manager 2007 Agent and Server versions via Powershell



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Scripts
  Comments: None

3/2/2008 - Updated versions throughout for SP1 (RTM) released in Feb ’08 

Although you generally check Pending Actions in the Console UI, the built-in cmdlets provide the means to easily retrieve agent and management server versions.

Returns Name, Version of all agent-managed machines
get-agent | ft DisplayName, Version

Returns which agents are not yet at SP1(RTM)
get-agent | where-object {$_.Version -notmatch ‘6.0.6278.0′ } | ft DisplayName, Version

Returns which agents are at SP1
get-agent | where-object {$_.Version -match ‘6.0.6278.0′ } | ft DisplayName

And of course you can do the same with your Management Servers
get-managementserver | ft Name, Version

Finally, you can also use Powershell for bulk approval of Pending Actions to update your agents with the Get-AgentPendingAction and Approve-AgentPendingAction cmdlets in a one-liner.

Get-AgentPendingAction | where {$_.AgentName -like “yourserver%”} |Approve-AgentPendingAction

Versions:
RTM = 6.0.5000.0
SP1 (RC) = 6.0.6246.0

SP1 (RTM) = 6.0.6278.0

SystemCenterForum has partnered with Infront Consulting to bring you the Operations Manager Bootcamp! Register in December for training in 2008 at SystemCenterForum and receive a free copy of Operations Manager 2007 Unleashed!

Check the 2008 Bootcamp Schedule and request pricing and availability HERE.


February 28, 2008



What agents report to management server? (one-liner)



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell
  Comments: 2 Comments

Just to show you there is almost always more than one way to solve a problem in the Command Shell. Some ways are just easier than others!

 I was looking at what apparently is one MS Internal suggestion for returning all the agents that report to a specific management server Stefan posted today.  A function, 10 or 12 lines of code, a variable to accept the MS name, etc. Fair enough. That totally works - but so does this one liner.

get-agent | where-object {$_.PrimaryManagementServerName -eq ‘Mgmt Svr FQDN’} | ft name


February 6, 2008



Tip: Scheduling Maint Mode for objects classes other than agents



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell
  Comments: 1 Comment

We published  a nice Powershell sample for putting a specific object (regardless of object class) awhile back (check it out HERE). Here’s a good example of how to put an website monitor into maintenance targeting the object display name.

  • Replace “Web Application Name” with the Display Name with that on your monitor.

  • Replace the 60 with the number of minutes you’d like to throw the object into maintenance.

 $Now = get-date

$WebAppObject = get-monitoringobject | where {$_.DisplayName –eq “Web Application Name”}new-maintenancewindow -starttime $Now -endtime $Now.addminutes(60)
–comment “Nightly shutdown” –monitoringobject $WebAppObject

Wrap that up with the connection string to connect to your management group and save as a .ps1 file and you can schedule it in a task to run nightly!

Thanks to Graham for posting the additional example on the original post.

Update your MOM skills to Operations Manager 2007 at the Operations Manager 2007 Bootcamp!

Check the 2008 Bootcamp Schedule and request pricing and availability HERE.


February 5, 2008



Creating an ad-hoc report of critical alerts in Operation Manager 2007



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell
  Comments: None

Q: How can I run a report showing all opening alerts of a particular severity?

A: An easy way to this is to simply use Powershell and export rules
that are both unresolved and critical to an Excel spreadsheet.

In the example below, we use select-object cmdlet to select the fields we want to include in our report and the export-csv cmdlet to export the output to csv file we can open in Excel.

get-alert | where-object {$_.ResolutionState -lt 255} | where-object {$_.Severity -eq “Error”} | select-object Name, Severity, Description | export-csv “c:\alerts.csv”

If you want to see all available fields, temporarily removing the formatting elements off the end and run the script again to return alerts meeting the criteria to the screen.

get-alert | where-object {$_.ResolutionState -lt 255} | where-object {$_.Severity -eq “Error”}

Then put them back, adding any add’l fields you want to the comma-separated list in the select-object list. You can even schedule this to run on scheduled basis with Scheduler on any computer with the OpsMgr Command Shell loaded.


January 15, 2008



Resolve Alerts Older Than X Days in Operations Manager 2007



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Scripts
  Comments: None

I’ve had a few requests for a way to resolve old alerts on a scheduled basis, as we did with a command line utility in MOM 2005.

This Powershell script retrieves open alerts and makes a date comparison based on the LastModified property of the alert and a user-defined alert age threshold.  It contains the standard connection string, so the script can run as a scheduled task to maintain a rolling set of only X days open alerts.

Get it HERE.


January 4, 2008



Prep for Agent-based Tasks with GPO Templates for Powershell



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Tools & Utilities
  Comments: None

These GPO templates allow controlling execution policy via group policy. A handy shortcut if you wanted to deploy Powershell to your servers and employ agent tasks that call Powershell scripts.

Get them HERE.


December 9, 2007



HOW-TO: Embed scripts of all kinds in OpsMgr 2007 Mgmt Packs



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell
  Comments: None

Derek Harkin has kindly put together an excellent explanation stepping through the process of embedding scripts other than VBScript / JScript in Operations Manager 2007 management packs. Check it out HERE.

Derek doesn’t use CDATA to wrap his scripts in MPs because the MP Authoring Console and the XML editors he uses automatically escape special characters. If you’re a Notepad user for XML editing, be careful with this.

If you need an XML editor, Derek mentions he uses Notepad++ with the XML Tools plug-in, which automatically escape the special characters. I am also a fan of MS XML Notepad 2007 for quick edits of existing MPs.

Great work Derek!


October 19, 2007



Create a new Reporting User Role using Powershell



  Posted by: Neale
  Categories: News, Operations Manager 2007, Powershell, Scripts
  Comments: None

Eugene Bykov posted a Powershell snippet that will add a new Reporting User Role in Operations Manager.  You can view the original post at the following URL:

http://blogs.msdn.com/eugenebykov/archive/2007/10/13/creating-new-report-operator-user-role.aspx

I have modified the script to work from the command line with the following parameters.

Parameters:
rootMS:
The FQDN or NetBIOS name of the Root MS.

roleUserName: The name User Role.

roleDisplayName: The Display Name of the role.

roleDescription: The description of the role.

 

Sample Command Line:

Powershell ./AddReportingUserRole.ps1 rootMS.server.local DBTestRole ‘Test DB Role’ ‘A test role created by Powershell’

 

You can download the updated script here.




Enable ACS in bulk through Powershell



  Posted by: Neale
  Categories: ACS, News, Operations Manager 2007, Powershell, Scripts
  Comments: None

This script was provided during the Operations Manager 2007 Beta by Joseph Chan @ Microsoft.  The original script enabled ACS on all agents to the provided ACS collector.  I have copied this script and modified it to take the Display Name of the group as a parameter so you can control what agents are enabled.

You can download the All Agents Bulk Enable here.

Parameters:
rmsServerName: The FQDN of the root
collectorServerName: The FQDN of the ACS Collector

 

You can download the Display Name Bulk Enable here.

Parameters:
rmsServerName: The FQDN of the root
collectorServerName: The FQDN of the ACS Collector
displayName: The display name of the group.  Ex: ‘Sample group’




List Ops Mgr Group Membership using Powershell



  Posted by: Neale
  Categories: News, Operations Manager 2007, Powershell, Scripts, Tips -n- Tricks
  Comments: None

There are two scripts available in the downloads area that will allow administrators to list group membership and output that data to a text file. The scripts work the same except they require two different types of input to identify the group.

The first script requires the Display Name of the group to find it.  Here is the syntax of the script and the link to download it.
Syntax:
rootMS:
the root management server. It can be a NetBIOS name or FQDN. 
Ex: rootMS.server.local
groupName: The display name of the group like "All Computers Group"
pathName: The path and file name that the script will write the results to.

Sample Command Line:

Powershell ./ListGroupMembersUsingDisplayName.ps1 rootMS ‘All Computers’ c:\test.txt

You can get the Display Name version here.

The second script requires the Path Name of the group to find it.  Here is the syntax of the script and the link to download it.
Syntax:
rootMS:
the root management server. It can be a NetBIOS name or FQDN. 
Ex: rootMS.server.local
groupPath: The display name of the group like "Microsoft.SystemCenter.AllComputersGroup"
pathName: The path and file name that the script will write the results to.

Sample Command Line:

Powershell ./ListGroupMembersUsingDisplayName.ps1 rootMS Microsoft.SystemCenter.AllComputersGroup c:\test.txt

You can get the Path Name version here.


August 21, 2007



Updating custom fields in alerts Operations Manager 2007



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell
  Comments: 1 Comment

I wanted to have some data written to custom fields in open alerts in Ops Mgr, and was trying to determine how I could automate this process. It was a simple | task in MOM 2005. Not so in Operations Manager 2007.

While the product documentation still includes a reference to a global location for customizing the custom fields available on alerts in Ops Mgr 2007

Operations Manager 2007 Global Management Group Settings - Alert Dialog Box: Custom Alert Fields Tab

However, one cannot help but notice that the Custom Alerts Field tab is conspicuously absent in the Operations Console UI. As it turns out, this capability was removed from MOMv3, and may be returned to product, but not before MOMv4.

So how can I can update custom fields on alerts being generated?

Well, we could do something with Powershell, but there is no good way to automate this process into an alert response that I can see…perhaps something could be done with a task launching a Powershell script I suppose, but not ideal.

Example of updating custom fields with Powershell

$alert = Get-Alert | where {$_.<Propertyhere> -eq ‘<valuehere>’}
$alert.CustomField1 = “Exchange Admins handling this”
$alert.Update(”")

How should we automate this process?

Says Jakub from the Ops Mgr product team, “The recommended approach for accomplishing tasks like this on subsets of alerts is to use the Connector Framework, creating a connector and subsequent subscription for that connector. This requires writing code for the connector to read the alerts from its subscription(s) and act on them.”

I guess I’ll be waiting for MOMv4 in hopes that this functionality is returned to the product.


August 8, 2007



Add Powershell to your list of SCE 2007 Prerequisites…



  Posted by: Pete
  Categories: Essentials 2007, News, Powershell
  Comments: None

As you may be aware, Powershell is not amongst the prerequisites for Essentials 2007, but perhaps it should be.

I came across the following error in the Ops Mgr log on one of our SCE Servers. The error is related to the rule in the System Center Internal Library that runs a Powershell script to check for management pack updates. This is important functionality, so be sure to add Powershell to your list of prerequisites in any SCE installation.

Error Details:

Event Type: Error
Event Source: Health Service Modules
Event Category: None
Event ID: 21400
Date: 8/7/2007
Time: 8:32:29 PM
User: N/A
Computer: RSM01
Description:
Failed to create process due to error ‘0×80070003 : The system cannot find the path specified.
‘, this workflow will be unloaded.

Command executed: “C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe” . ‘”D:\Program Files\System Center Essentials 2007\Health Service State\Monitoring Host Temporary Files 6\7101\MPUpdate.ps1″ -MPVersionFileUrl:’http://go.microsoft.com/fwlink/?LinkId=57329′
Working Directory: D:\Program Files\System Center Essentials 2007\Health Service State\Monitoring Host Temporary Files 6\7101\

So install Powershell to address this issue. And while you’re at it, kick it up a notch! Install your own SCE Command Shell and explore. See SCE 2007 Command Shell for more details.


August 7, 2007



View all Ops Mgr 2007 objects in Maintenance from Powershell



  Posted by: Neale
  Categories: News, Operations Manager 2007, Powershell
  Comments: None

Boris Yanushpolsky updated his blog recently (link) that included a Powershell function that would show all objects in maintenance. I thought this was very cool but I wanted to see how our Systemcenterforum.org maintenance mode script (link) would work with this script. When I tested this against our lab domain controller, the results were good. The script from Boris reported all objects on the server that was in maintenance. Below is a snippet of what was reported to be in maintenance:

DisplayName : Windows Time
Object Type : Windows Time
Start Time : 8/7/2007 4:16:24 PM
End Time : 8/7/2007 4:21:24 PM
Path : NOCDC01.noc.momresources.org;NOCDC01
User : MOMRESOURCES\Administrator
Reason : SecurityIssue
Comment :

DisplayName : Default Web Site
Object Type : IIS 2003 Web Site
Start Time : 8/7/2007 4:16:24 PM
End Time : 8/7/2007 4:21:24 PM
Path : NOCDC01.noc.momresources.org
User : MOMRESOURCES\Administrator
Reason : SecurityIssue
Comment :

DisplayName : NOCDC01
Object Type : Active Directory Domain Controller Server 2003 Computer Role
Start Time : 8/7/2007 4:16:24 PM
End Time : 8/7/2007 4:21:24 PM
Path : NOCDC01.noc.momresources.org
User : MOMRESOURCES\Administrator
Reason : SecurityIssue
Comment :


July 10, 2007



Automate MP Export for Disaster Recovery



  Posted by: Neale
  Categories: News, Operations Manager 2007, Powershell
  Comments: 5 Comments

If you want to automate the backup of sealed or unsealed MPs for disaster recovery, then this will help. This Powershell script will initiate the Ops Mgr Console to export all un-sealed Management Packs to the specified directory.  You can run this from Ops Mgr 2007 or from the OS Scheduler.

Powershell c:\export-UnSealedMP.ps1 -rootMS rms.server.local -targetFilePath ‘c:\backup\mp’

 

-rootMS: Enter the FQDN of the RMS

-targetFilePath: the target path of the MP backup files

 

You can download the script from here:

http://systemcenterforum.org/wp-content/uploads/exportUnSealedMP.zip


July 7, 2007



Securing Report Access in Operations Manager 2007



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Reports, Uncategorized
  Comments: None

I think at this point in time, most Ops Mgr admins don’t think report visibility can be restricted at a granularity beyond the default Report Operators group. In fact, nothing could be further from the truth. In reality, visibility to Operations Manager reports can be restricted to custom Report Operator user roles at the folder level, or even the individual report level in Operatoins Manager 2007….but not through the Operations Console GUI.

Working with Microsoft PSS to solve this issue for a customer, Mike Betts (www.momanswers.net) has successfully naviagated these waters, and through a mix of GUI, Powershell and reporting site configuration, and has kindly shared his documentation and explanation of the process for securing and restricting visibility Ops Mgr reports.

Download Mike’s tutorial at the URL below:

http://systemcenterforum.org/wp-content/uploads/Securing_Reports_OpsMgr_v1.0.pdf

Did you know? Mike Betts was the 1st MOM MVP when MOM 2000 was released by Microsoft.


June 25, 2007



Tip: Dumping all overrides in Operations Manager 2007



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell
  Comments: None

Want a quick way to view ALL overrides in your Operations Manager 2007 installation?

Here’s a one-liner to dump all overrides in descending order by LastModified date to a spreadsheet, which should tip you off to recent changes enacted via override.

get-ManagementPack | where {$_.Name -like “*” } | get-Override |sort-object LastModified -descending | select-object name, displayname, xmltag, value, timeadded, lastmodified | export-Csv -Path “c:\overrides.csv”

While not perfect, the Name attribute provides some insight into the purpose of the override. Unfortuntely, not all overrides have a friendly name (DisplayName), and I didnt see any trace of who made the changes in the verbose output. The xmltag attribute does reveal if the override is applied to a rule, monitor, etc (values I encountered were RuleConfigurationOverride, MonitorConfigurationOverride, CategoryOverride). The value parameter the current value data for the given override.

In the future I’ll look further into the potential of connecting overrides to their associated rules / monitors for inclusion in the output.


June 13, 2007



Scheduling Maintenance for an Object in Ops Mgr 2007



  Posted by: Neale
  Categories: News, Operations Manager 2007, Powershell
  Comments: 5 Comments

Since we have posted the Powershell script to put OpsMgr 2007 computers into maintenance, users have asked us how to put a service or application into maintenance, allowing other monitoring activities on a server to continue. We have figured out how to implement maintenance at this more granular level and have outlined the steps below using IIS as an example. The key to this working is that whatever application/service you want to put into maintenance, must be configured as an object in OpsMgr 2007.
*NOTE* In this example, Step 1 is looking for the NetBios name of the server. Please replace “PUT_SERVER_NAME_HERE” with the server of your choice.

Step: 1
$agent = get-agent | where {$_.ComputerName -eq “PUT_SERVER_NAME_HERE”}

Step: 2
$object = $agent.HostComputer.GetRelatedMonitoringObjects() | where {$_.DisplayName -eq “Microsoft.Windows.InternetInformationServices.2003.ServerRole”}

Step: 3
$time = date

Step: 4
$object | New-MaintenanceWindow -startTime $time -endTime: $time.AddMinutes(5) -reason: “UnPlannedOther” -comment: “I luv IIS!”

If you want a longer maintenance window, just increase the number in the parameter $time.AddMinutes(5). For example, to set a 10 minute window, just make the parameter to look like this $time.AddMinutes(10).

We will come out with a script in the near future that will put well-known MS applications into maintenance (assuming the MP is properly designed).




New System Center Webcasts for June



  Posted by: Pete
  Categories: Configuration Manager 2007, News, Operations Manager 2007, Powershell
  Comments: None

And thank you Ian!

TechNet Webcast: System Center Operations Manager 2007 Technical Overview (Level 200)
Monday, June 11, 2007 - 11:30 AM - 1:00 PM Pacific Time
Chris Avis, IT Pro Evangelist, Microsoft Corporation
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032340807&Culture=en-US

TechNet Webcast: Client Monitoring with System Center Operations Manager 2007 (Level 200)
Monday, June 18, 2007 - 11:30 AM - 1:00 PM Pacific Time
Blain Barton, IT Pro Evangelist, Microsoft Corporation
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032341227&Culture=en-US

TechNet Webcast: What’s New in Systems Management Server 2003 SP3 (Level 200)
Tuesday, June 19, 2007 - 1:00 PM - 2:00 PM Pacific Time
Wally Mead, Senior Program Manager, Microsoft Corporation
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032341247&Culture=en-US

TechNet Webcast: System Center Operations Manager 2007 Installation and Management Pack Migration (Level 200)
Friday, June 22, 2007 - 1:00 PM - 2:30 PM Pacific Time
Bryan Von Axelson, IT Pro Evangelist, Microsoft Corporation
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032341253&Culture=en-US

TechNet Webcast: Introduction to System Center Configuration Manager 2007 (Level 200)
Tuesday, June 26, 2007 - 1:00 PM - 2:00 PM Pacific Time
Wally Mead, Senior Program Manager, Microsoft Corporation
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032341255&Culture=en-US

TechNet Webcast: Microsoft Windows PowerShell: The Future of Server Administration (Level 300)
Tuesday, June 05, 2007 - 10:00 AM - 11:15 AM Pacific Time
Don Jones, Scripting Guru and Author, SAPIEN Technology
http://go.microsoft.com/fwlink/?LinkId=90647

TechNet Webcast: Under-the-Hood Extensions in Windows PowerShell (Level 200)
Tuesday, June 19, 2007 - 11:30 AM - 12:30 PM Pacific Time
Don Jones, Scripting Guru and Author, SAPIEN Technology
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032321876&


May 11, 2007



Find a rule using Powershell in Ops Mgr 2007



  Posted by: Neale
  Categories: Articles, News, Operations Manager 2007, Powershell
  Comments: None

I was trying to find out if a rule was deployed to a particular set of servers but I couldn’t find a quick way to do it. It is not that I don’t trust my overrides to work but I would just like to verify that they are working as intended. I have written a script that will search a particular group for machines running a given rule specified by the rule display name. It is not very pretty but it will get the job done.

Here is a sample command line:

 This example will search all agent-managed computers for presence of a particular rule.

powershell .\findrule.ps1 -rootMS nocrms01.noc.momresources.org -groupPathName Microsoft.SystemCenter.AgentManagedComputerGroup -ruleDisplayName ‘Collect Discovery Data’

Here is where you can get the script.
http://systemcenterforum.org/wp-content/uploads/FindRule.zip


May 3, 2007



Managing your overrides (end-to-end) in Ops Mgr 2007



  Posted by: Pete
  Categories: News, Operations Manager 2007, Powershell, Scripts
  Comments: None

As he originally mentioned in the Active Directory MP Guide, overrides should be stored in a custom MP created by the Ops Mgr admin expressly for that purpose. This ultimately creates the need to persist the Default MP. For full post, see HERE.

But what do you do if you created overrides before you knew this ? (that would be ME!) To address probability, Jonobie goes on to explain how to eliminate your dependence on the Default Management Pack HERE

Finally, just as in MOM 2005, you need to back these up for safekeeping outside the normal Operations database backups to avoid doing a full database restore if something is removed, altered or deleted unintentionally per my original post with a script to backup all unsealed MP’s HERE


May 1, 2007



SCE 2007 Command Shell



  Posted by: Neale
  Categories: Essentials 2007, News, Powershell
  Comments: 1 Comment

Here is a link to a document that will walk through how to customize Powershell on a SCE 2007 Management Server to use the SCE 2007 SDK. Since SCE doesn’t have a Command Shell like OpsMgr 2007 for bulk and scheduled admin tasks, we thought it would be nice for Administrators to have the ability to control SCE 2007 from Powershell! This is a work-in-progress please leave comments or requests.

http://systemcenterforum.org/wp-content/uploads/SCECmdShellEnv.pdf


April 4, 2007



Exporting open OpsMgr 2007 alerts to HTML through Powershell



  Posted by: Neale
  Categories: News, Operations Manager 2007, Powershell
  Comments: None

Ever wanted an easy way to export a certain number of alerts (depending on the search criteria) for use later? Well, Operations Manager 2007 gives us that power using its Powershell provider. To use this functionality, you will need to use the Command Shell that is group with Operations Manager 2007 in the Start Menu. You can also invoke Command Shell from within the UI through the Monitoring Pane

Well, to get a list of all alerts from your management group, just run the following command:

PS Monitoring:\NOCRMS01.noc.momresources.org > Get-Alert

This will bring back a list of all alerts for the Management group that NOCRMS01 is a part of.

If your environmnt is large, you may want to filer your results by using the cmdlet Where-Object (also known as Where). Here is an example of all alerts in a Severity State of Warning and a Resolution of New:

> get-alert | where {$_.Severity -eq “Warning” -and $_.ResolutionState -eq 0 }

Now lets say you want to save the alerts from the previous example into an HTML file for easy viewing.. Here is the set of commands you can do to achieve that:

> $alert = get-alert | where {$_.Severity -ge “Warning” -and $_.ResolutionState -eq 0 }
> $alert | ConvertTo-Html | set-content c:\test.html

Or you can type it all in 1 line:

> get-alert | where {$_.Severity -eq “Warning” -and $_.ResolutionState -eq 0 } | ConvertTo-Html | set-content c:\test.html

This will convert the data from $alert variable into HTML (using the ConvertTo-HTML cmdlet) and then write the data to test.html located on the root of C:.

You can also get the alert history from the previous example and output that to HTML by running the following commands:

> $alert = get-alert | where {$_.Severity -eq “Warning” -and $_.ResolutionState -eq 0 }
> $alert | get-alerthistory | ConvertTo-Html | set-content c:\test2.html

Or

> get-alert | where {$_.Severity -eq “Warning” -and $_.ResolutionState -eq 0 } | ConvertTo-Html | set-content c:\test2.html

This the same export process as from the previous example except that we are saving the file to test2.html.

The final touch will be closing the same alerts we were searching for in the previous examples. If you wanted to, you can run this command with multiple pipe statements to pass the object from one command to another but it will look confusing so I am passing the results into variables.

> $alert | resolve-alert -comment: “Resolved by Powershell”

This all for now but as I learn more and find interesting statements, I will pass them on. In the meantime, check out the System Center Command Shell blog located at http://blogs.msdn.com/scshell/. There are awesome examples of using the OpsMgr 2007 Powershell provider.


March 30, 2007



Advanced Powershell Script Samples from MMS 2007



  Posted by: Pete
  Categories: News, Powershell
  Comments: None

Jeffrey Snover from MMS has made available the deck and scripts from his Advanced Powershell presentation at MMS 2007.

Down a copy HERE.


Privacy Policy | Terms of Use | © 2005-2007 Pete Zerger