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

Scripts



July 2, 2008



Sample scripts for use in 2-state monitors in Operations Manager and Essentials



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

Here are a couple of sample scripts we’ve heard requests for repeatedly now available for download. The scripts are designed to be used in a 2-state monitor in either Operations Manager 2007 or Essentials 2007.

Registry value Check script - This script facilitates checking the value of a user-defined registry key to update a 2-state monitor in Operations Manager 2007. Error checking ensures state is updated in the event the registry key is not found.

Windows Process Check script - This script facilitates checking to ensure a given Windows process is running, and that the desired number of instances of the process are running.

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.


April 11, 2008



Windows Network Share File Copy Response Script



  Posted by: Neale
  Categories: Essentials 2007, Management Packs, News, Operations Manager 2007, Scripts
  Comments: 1 Comment

I created a script for a customer to measure the response time of SMB file share (Windows File Share) to test new network equipment.  I thought that this script might be useful to someone in the community so I dressed it up a bit and created two versions of it.  You can download the scripts in a MP form here

The versions of the script are as follows:

  • Single File Share - The script will copy the file to a single server share and log the response time.  The script will log an event if it succeeds or fails.
  • Multiple File Share - The script will copy a file to multiple servers with the same share.  This script will also log an event if it succeeds or fails.   

Both sample scripts listed above and included with rules in the MP as an example on how to use it.  Included in the download is a readme file that explains the command line parameters.

I am fairly sure this can work in SCE but I haven’t tested it so I would really appreciate some feedback from anyone that tries it.


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.


January 18, 2008



Scripting Series (Part 2): Custom Performance Objects in Runtime Scripts



  Posted by: Pete
  Categories: Essentials 2007, Management Packs, News, Operations Manager 2007, Scripts
  Comments: 2 Comments

Part 2 of the SCF Scripting Series is now available for download. In this installment, we build on our work from part 1 to write file size data to a custom performance object. All work is compatible with System Center Operations Manager 2007 RTM / SP1 and Essentials 2007 RTM / SP1

  • Download the article HERE.
  • Download the accompanying script and management pack are available HERE.

As always, questions, comments and arrata are welcome via the contact page.


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.


December 23, 2007



“Best of MOM 2005″ Holiday Countdown - Day 5



  Posted by: Pete
  Categories: MOM 2005, News, Scripts, Tools & Utilities
  Comments: None

Resolve alerts via e-mail in MOM 2005

#3 in our countdown is this freeware solution that allows MOM 2005 administrators to actually acknowledge or resolve alerts via e-mail!

David Wallis wrote this app, which runs as a Windows service, called the MOM Email Service, that allows MOM administrators to acknowledge and resolve alerts via email. You essentially setup a mailbox for the service, and by replying to the alert with the word “acknowledged” or “resolved”, the service updates the status of the alert.

If you’re running MOM 2005 Notification Workflow, it does require a small edit to the NWSA XML config files, but I tested and documented all that in detail.

Download the MOM 2005 E-Mail Response Service HERE.


December 11, 2007



Writing and debugging OpsMgr 2007 scripts without a console



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

Q: Is there an Operations Manager 2007 equivalent of the ResponseTest Resource Kit utility?

A: According to the OpsMgr 2007 SDK, all you need to do is copy the MOMScriptAPI.dll from any management server to your workstation. Then use regsvr32 to register the dll, and you are ready to go! You can then write, run and debug Operations Manager runtime scripts on your XP or Vista workstation - no console required. Script output is returned to the screen in xml. This allows you to check the data being returned by your script before you go to the work

The problem: However, when I tried this, registering the dll failed with a “Loadlibrary (MOMScriptAPI.dll) failed” error.

The fix: A little work with Process Monitor revealed that the HealthServiceRuntime.dll was being called, but was absent. Simply copying HealthServiceRuntime.dll to the same directory as the MOMScriptAPI.dll and then running regsvr32 MOMScriptAPI.dll again solved the problem.

To Test: Perform the above steps and then run this simple ping script from a command line (which pings localhost). Propertybag data will be returned in your console.

Have fun!


November 30, 2007



SNMP Device Polling via Scripts in MOM 2005



  Posted by: Neale
  Categories: MOM 2005, News, Scripts
  Comments: None

If you want to use SNMP polling in MOM 2005, you have to use WMI with scripting to make that happen.  I don’t know if you have tried to use WMI to poll SNMP devices, but it is not very easy if you have to import a MIB.   I found an easier way to poll SNMP devices in MOM 2005 by using a freeware DLL and polling the SNMP devices via scripting.  The DLL is called System Scripting Runtime and it can do a number of things but most importantly it can do SNMP polling based off the OID on SNMP devices. 

In the Downloads section of the site is a file called SNMPPoll2005.zip that contains a sample script to poll a single IOD.  This script will log an event if polling the OID fails or if a logic condition is not met. The script is designed to run on an interval and another rule checks for a certain event ID and alerts on that. 

Argument 1 - DeviceName :target device (ex: 192.168.0.43)
Argument 2 - CommunityString : Community string (ex: public)
Argument 3 - OID :  The identifier to poll on the SNMP device (ex: 1.3.6.1.4.1.9.9.27)

System Scripting Runtime

Info: http://www.netal.com/ssr.htm

Download: http://www.netal.com/Software/SSR15.ZIP

SNMP Polling Script

Download: http://systemcenterforum.org/wp-content/uploads/SNMPPoll2005.zip


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.


September 10, 2007



Handy SQL queries for MOM 2005…



  Posted by: Pete
  Categories: MOM 2005, News, Scripts
  Comments: None

Scott Moss wanted to share a couple of SQL queries that might come in handy for ad-hoc queries or custom reports in MOM 2005. Thanks Scott!

SQL Script 1:

MOM 2005 SQL Query to return Only Managed computers that belong to a Computer Group. This query returns only Agent Managed Computers names for a specific Computer group.

The results will not include Cluster Server names.

 

select [Name] from ComputerWHERE [IsConfigManager]=0 AND ManagedType = ‘2′ AND(idConfigManager IS NULL OR idComputer <> idConfigManager) ANDIsAddedByServiceDiscovery = 0 AND [Type] <> 67108864 AND [Name] in (SELECT [ComputerName]FROM [OnePoint].[dbo].[SDKComputerToComputerGroupView]WHERE ComputerGroupName = ‘YOUR COMPUTER GROUP NAME HERE’)ÂÂ

– END SQL CODE

SQL SCRIPT 2:

The following SQL Script will return a count of the number of computers that belong to each computer group in your OnePoint Database. This count includes all computers that is in the OnePoint Database, which includes Discovered, Unmanaged and Managed computers. This query can help you identify possible problems with a group or when troubleshooting why Computer group modifications in the Management console take a long time.

SELECT [Rule], COUNT(*) AS [Members]FROM computertocomputerruleviewgroup by [Rule]order by [Members] desc


August 3, 2007



CreateTypedPropertyBag value parameter solved!



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

 

Thanks to Derek Harkin, we now have the values accepted by the  CreateTypedPropertyBag(value) method and what they relate to.

0 = Alert
1 = Event
2 = Performance Data
3 = State Data

For more information about this method, see our article called HOW-TO guide for Ops Mgr 2007 Admins use custom scripts to log performance data.


July 6, 2007



HTTPS (SSL) Monitoring with MOM 2005 the easy way



  Posted by: Pete
  Categories: MOM 2005, News, Scripts
  Comments: None

We originally posted this last year, but noticed it didn’t make it into the new site…enjoy.

I am sure I’m not the only one irritated with the lack of SSL support in the Web Sites & Services MP via the sequence capture tool (you can manually edit captures sequences to manually SSL support to a sequence), along with the need to actually capture a sequence for every URL you wish to monitor. Enter the ServerXMLHTTP object, which is native to Windows 2003, Windows XP and Windows 2000 SP3 and later. It’s native, very stable, and offers support for SSL and authentication beyond what is possible with the Web Sites & Services MP.

Here’s an HTTP monitoring script from one of my engineers that delivers:

  • Monitor HTTP / HTTPS URL
  • Compare a user provided string against content returned.
  • Performance charts for response time and availability
  • Alerts on response latency

Script Parameters:

  • URL: Can be HTTP or HTTPS
    ex. http://www.microsoft.com SearchString: Text string that should be somewhere in the HTML code.
  • ChartAvailability: Set to 1 if you want to chart your availability. If it set, it will log a performance counter with a value of 1 to signify it is up. A zero to signify it is down.
  • LogSuccess: Enables the processing of successful logging of alerts and events. For Troubleshooting only.
  • Threshold: A response time threshold in seconds for the site to return the data. If the site exceeds this time, then it will raise an alert. Set to 0 if you want to disable (will also disable the performance counter logging as well).

Get it HERE: http://systemcenterforum.org/wp-content/uploads/httpmonitor.txt


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


March 9, 2007



Responding to Alerts via Email in MOM 2005



  Posted by: Pete
  Categories: HOW-TO Guides, MOM 2005, Scripts
  Comments: None

01/17/2007 - David Wallis of the U.K (www.wallis2000.co.uk) has written an application, called the MOM Email Service, that allows MOM administrators to acknowledge and resolve alerts via email.

Read more HERE.

Download the application and installation guide HERE.


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