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

Scheduling Maintenance for an Object in Ops Mgr 2007



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

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).

5 Responses to “Scheduling Maintenance for an Object in Ops Mgr 2007”

  1. Graham Pohl Says:

    I’m trying to put a web application (Not Agent monitored IIS, this is a linux box without agent monitoring, using the Web Application monitor) into Maint mode, but can’t figure out which object to use.

    Presumably I have to use get-agent | where {$_.DisplayName -eq AppName} or something similar. Can anyone help me with how to find the correct object.

    Thanks,

  2. Graham Pohl Says:

    Okay, I managed to figure this out myself in the end, and this syntax seems to work…

    $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

  3. System Center Forum - Tip: Scheduling Maint Mode for objects classes other than agents Says:

    […] 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 […]

  4. Matt Mccomas Says:

    Can the above be configured on the scom server or a jobs server so that each time a server performs a scheduled reboot it can automatically place itself in maintenance mode? We have a scheduling server and ideally I’d like for each server to place itself in maintenance mode just prior to being rebooted.

  5. System Center Forum - Collection of Maintenance Mode Scripts, Utilities and MPs for Opsmgr and Essentials 2007 Says:

    […] the code snippet for maintenance mode for any object class HERE or […]

Leave a Reply

You must be logged in to post a comment.


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