none
SCOM 2012R2 - Powershell script to turn off/on Maintenance Mode for servers RRS feed

  • Question

  • I've been tasked to write a simple PowerShell script to place servers in Maintenance mode in SCOM

    We are running SCOM 2012 R2.

    I'm new to Powershell. Any suggestions to write this script?

    Kind regards for your help.

    Sunday, November 24, 2019 8:16 PM

Answers

  • The Start-SCOMMaintenanceMode is used to put a server in maintenance mode.

    Now, depending on your exact requirement, the script itself may be very different... does it need to put in MM a bunch of servers? If yes, where do you get their list? CSV file? SCOM group? SQL db?

    Does the maitenance mode need to be triggered individually from an agent?

    You will find pretty easily quite a few examples for these different scenarios... Let us know if you are facing any issue :)

    Sunday, November 24, 2019 8:24 PM
  • Yes, you can use the following script

    https://gallery.technet.microsoft.com/scom-maintenance-mode-6df70580

    It is working with SCOM 2012 R2.

    First, create groups with objects using SCOM console.

    Second, edit script config file (specify group names and schedule for each group).

    Then you can run script. In order to stop script, press F12.

    Sunday, November 24, 2019 11:34 PM
  • Hi,

    In operations manager, computers, hard disks, logical disks, sql databases, network adapters, and so on, are monitoring objects, which we called instances.

    We can put any monitoring objects into maintenance mode, for example, we may put all the hard disk into MM. The following cmdlets will do the trick:

    Import-Module OperationsManager
    New-SCOMManagementGroupConnection -ComputerName <management server>
    $Instance = Get-ScomClassInstance -DisplayName "Hard Disk"
    $Time = ((Get-Date).AddMinutes(30))
    Start-SCOMMaintenanceMode -Instance $Instance -EndTime $Time -Comment "put object in MM" -Reason "PlannedOther"

    If we want to put a specified object into MM, we may use this:

    $Instance = Get-SCOMClassInstance -Id ee0225e2-6f89-2f3c-e89d-002e1bc220c5

    To get all the monitoring objects (including windows computers) with Id, use the following command:

    Get-SCOMClassInstance | export-csv c:\temp\scom_instance.csv

    The sample screenshot in my lab:



    Hope the above information helps.

    Regards,

    Alex Zhu
    -----------------------------------------------
    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
    Monday, November 25, 2019 8:53 AM

All replies

  • The Start-SCOMMaintenanceMode is used to put a server in maintenance mode.

    Now, depending on your exact requirement, the script itself may be very different... does it need to put in MM a bunch of servers? If yes, where do you get their list? CSV file? SCOM group? SQL db?

    Does the maitenance mode need to be triggered individually from an agent?

    You will find pretty easily quite a few examples for these different scenarios... Let us know if you are facing any issue :)

    Sunday, November 24, 2019 8:24 PM
  • Yes, you can use the following script

    https://gallery.technet.microsoft.com/scom-maintenance-mode-6df70580

    It is working with SCOM 2012 R2.

    First, create groups with objects using SCOM console.

    Second, edit script config file (specify group names and schedule for each group).

    Then you can run script. In order to stop script, press F12.

    Sunday, November 24, 2019 11:34 PM
  • Hi,

    In operations manager, computers, hard disks, logical disks, sql databases, network adapters, and so on, are monitoring objects, which we called instances.

    We can put any monitoring objects into maintenance mode, for example, we may put all the hard disk into MM. The following cmdlets will do the trick:

    Import-Module OperationsManager
    New-SCOMManagementGroupConnection -ComputerName <management server>
    $Instance = Get-ScomClassInstance -DisplayName "Hard Disk"
    $Time = ((Get-Date).AddMinutes(30))
    Start-SCOMMaintenanceMode -Instance $Instance -EndTime $Time -Comment "put object in MM" -Reason "PlannedOther"

    If we want to put a specified object into MM, we may use this:

    $Instance = Get-SCOMClassInstance -Id ee0225e2-6f89-2f3c-e89d-002e1bc220c5

    To get all the monitoring objects (including windows computers) with Id, use the following command:

    Get-SCOMClassInstance | export-csv c:\temp\scom_instance.csv

    The sample screenshot in my lab:



    Hope the above information helps.

    Regards,

    Alex Zhu
    -----------------------------------------------
    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
    Monday, November 25, 2019 8:53 AM
  • Hi,

    It seems there is no update for a couple of days. May we know the current status of the problem? Is there any other assistance we can provide?

    Regards,

    Alex Zhu
    -----------------------------------------------
    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
    Monday, December 2, 2019 5:09 AM