Answered Maintenence mode on all MPs

  • Sunday, February 17, 2013 11:37 AM
     
     

    Hi All,

    I want to put all my MPs except the health library MP in Maintenance mode.

    The result i need:

    There will be no monitoring except heartbeat to the servers.

    Anyone have a script like this in power shell?

    Thanks

All Replies

  • Sunday, February 17, 2013 2:30 PM
     
     

    Please refer to the following link for how to put computer in maintenance mode
    http://gallery.technet.microsoft.com/scriptcenter/17eebf90-f6c7-46ba-9229-2bbde819aab2
    http://www.scomgod.com/?p=86

    Roger

  • Monday, February 18, 2013 7:45 AM
    Moderator
     
     

    Hi

    You don't put management packs into maintenance mode. You put discovered objects \ their classes into maintenance mode. E.g. SQL databases. So what you are looking to do isn't possible.

    If you follow Rogers link and put computers into maintenance mode then you won't get heartbeat alerts ...

    Regards

    Graham


    Regards Graham New System Center 2012 Blog! - http://www.systemcentersolutions.co.uk
    View OpsMgr tips and tricks at http://systemcentersolutions.wordpress.com/

  • Monday, February 18, 2013 7:51 AM
     
     

    Hi,

    OK so if i want to put all classes in  maintenance mode but to continue to receive heartbeat alerts how can i do it?

    Thanks 

  • Monday, February 18, 2013 7:52 AM
     
     

    Hello, 

    If you are looking at receiving alerts to your email and or sms only for heartbeat and no other alerts, then you can temporarily disable all the subscriptions and create a new subscription only to receive heartbeat alerts. 

    However, as Graham stated you can only put discovered objects in Maintenance Mode. So if you want to do that, you will have to go under each Management Pack (open state view) and put the objects in Maintenance Mode (this will basically put the class under Maintenance Mode) For example, if you open the SQL DB state view and put all the DB under Maintenance mode, it will put the entire class in Maintenance Mode. Similarly, you can do it for IIS, Exchange, AD etc (but this would be too much work)

    Let me know if this works for you!

    Regards,


    Abdul Karim. (http://sites.google.com/site/scomblogs Twitter:@Abdul_SCOM)

  • Monday, February 18, 2013 7:58 AM
    Moderator
     
     

    Hi

    You can't sensibly do it ... you'd have to put every class into maintenance mode ... if you want to stop email notifications then do this via the subscription rather than putting objects into maintenance mode.

    Cheers

    Graham


    Regards Graham New System Center 2012 Blog! - http://www.systemcentersolutions.co.uk
    View OpsMgr tips and tricks at http://systemcentersolutions.wordpress.com/

  • Monday, February 18, 2013 8:09 AM
     
     

    Hi,

    This is not a mail or SMS issue, i just want to put all discovered objects in Maintenance Mode (by using power shell and not manually in SCOM Console- state view).

    1. Can i do it by a power shell script with a loop query?

    2. I want to receive only heartbeat alerts, is it possible? 

  • Monday, February 18, 2013 8:56 AM
    Moderator
     
     

    In theory you can ... you just have to loop through every single class that has a rule or monitor targeted at it (except the class that is the target of the monitors you want to be alerted on) and put those classes into maintenance mode. It isn't good for for performance both in terms of actually putting the objects into maintenance mode or all the state changes that it will generate.

    Why do you want to do this? 


    Regards Graham New System Center 2012 Blog! - http://www.systemcentersolutions.co.uk
    View OpsMgr tips and tricks at http://systemcentersolutions.wordpress.com/

  • Monday, February 18, 2013 10:55 AM
     
     

    I have 2 management groups that are not connected (not clustered) and all my agents are reporting to both management groups.

    One management group is always up and the other needs to be in maintenance mode and receive only heartbeats .

    We will raise the second management group in a time of need.

    Do you know a better solution? (we don't have orchestrator or any other maintenance tool - SCOM2012)

  • Monday, February 18, 2013 11:14 AM
     
      Has Code

    Hi dorlm,

    To continue to receive heartbeat alerts, you need to make sure the 'Health Service Watcher' object for the server is not in maintenance mode. It's the watcher object that raises the heartbeat and 'failed to connect to computer' alerts.

    Probably the easiest way is to only put the health service (the 'agent') on the server(s) into maintenance mode.

    To do this in the SCOM console:

    Go to Operations Manager > Agent Details > Agent Health State, select the appropriate item(s) in the right-hand 'Agent State' pane, select Start Maintenance Mode. The equivalent items in the left-hand 'Agent State from Health Service Watcher' pane should not be in maintenance mode.

    In PowerShell, you would do something like this (for a single server):

    $serverName = "myserver.mydomain.local"
    Get-SCOMClass -Name "Microsoft.SystemCenter.HealthService" | Get-SCOMClassInstance | where { $_.DisplayName -eq $serverName } | Start-SCOMMaintenanceMode -EndTime ([DateTime]::Now).AddHours(1)

    This will disable all monitoring on the server, but you'll continue to receive heartbeat and 'failed to connect to computer' alerts. Is this what you were trying to do?

    Cheers, Richard 


    Richard Benwell www.squaredup.com

  • Monday, February 18, 2013 1:48 PM
     
     

    Yes thank you i will give it  a try!

    I just need to change this code to work in a loop on all servers.

  • Monday, February 18, 2013 1:50 PM
     
     

    Can you explain again where is the Operations Manager > Agent Details > Agent Health State?

    In the Monitoring tab?

  • Monday, February 18, 2013 3:02 PM
     
     

    Yes, sorry - under the monitoring tab, expand 'Operations Manager', then 'Agent Details', then select the 'Agent Health State' node.


    Richard Benwell www.squaredup.com

  • Tuesday, February 19, 2013 12:19 PM
     
      Has Code

    Hi Richard,

    If i understand correctly when i am putting an agent in maintenance mode (not the agent watcher) there will be no monitoring and alerts(except  heartbeat and 'failed to connect to computer')?

    Putting the appropriate item(s) in the right-hand 'Agent State' pane in maintenance mode is the same action as the command:

    Get-SCOMClass -Name "Microsoft.SystemCenter.HealthService" | Get-SCOMClassInstance | where { $_.DisplayName -eq $serverName } | Start-SCOMMaintenanceMode -EndTime ([DateTime]::Now).AddHours(1)

    ?

    How can i get a list of Agents ( the right-hand 'Agent State') to put in maintenance mode in powershell (and not the watcher)?

    $ListserverName =get-?

    Thanks!


  • Tuesday, February 19, 2013 3:44 PM
     
     Answered Has Code

    Hi dorlm,

    Looking at your reply to Graham, if you want to have these servers in maintenance mode for the long term then I suggest you put the whole server into maintenance mode, and not just the agent.

    You can do that by modifying the script I provided to get the 'Microsoft.SystemCenter.ManagedComputerServer' objects instead:

    Get-SCOMClass -Name "Microsoft.SystemCenter.ManagedComputerServer" | Get-SCOMClassInstance | where { $_.DisplayName -eq $serverName } | Start-SCOMMaintenanceMode -EndTime ([DateTime]::Now).AddHours(1)

    This is just an example. I recommend that you read the documentation on the Start-SCOMMaintenanceMode here. There are also plenty of other maintenance mode scripts and tools out there.

    When you put the whole computer into maintenance mode, you will find that the Agent and the Agent Watcher both go into maintenance mode. To receive heartbeat alerts you must stop maintenance mode on the Agent Watcher. This is the key step.

    Do this with the following script:

    Get-SCOMClass -Name "Microsoft.SystemCenter.HealthServiceWatcher" | Get-SCOMClassInstance | where { $_.DisplayName -eq $serverName } | foreach { $_.StopMaintenanceMode( [DateTime]::UtcNow, "OneLevel") }

    To get a list of all your server names you can use:

    $ListServerNames = Get-SCOMClass -Name "Microsoft.SystemCenter.ManagedComputerServer" | Get-SCOMClassInstance | Select -ExpandProperty DisplayName

    Important: Remember not to put all of your SCOM management servers into maintenance mode. Bad things can happen.

    Let me know if you need any more info.




    Richard Benwell www.squaredup.com

    • Marked As Answer by dorlm Wednesday, February 20, 2013 12:09 PM
    •  
  • Wednesday, February 20, 2013 9:59 AM
     
     

    Hi Richard,

    Thank you for the info.

    I am not going to put the management server in maintenance mode, only all the agents that reports it.

    Is something bad can happened?

    And one more question:

    Today my agents are reporting to 2 management servers (2 different management groups), if i am putting the servers in maintenance mode in one management server they will continue to report the second management server right?

    Thanks!

     

  • Wednesday, February 20, 2013 10:58 AM
     
     

    Is something bad can happened?

    Putting all of your management servers into maintenance mode stops important workflows (including the agent heartbeats and the workflow to automatically come out of maintenance mode!). See the 'important note' in this article and a couple of blogs (here and here).

    Today my agents are reporting to 2 management servers (2 different management groups), if i am putting the servers in maintenance mode in one management server they will continue to report the second management server right?

    That's right! Good luck with it all.


    Richard Benwell www.squaredup.com

  • Wednesday, February 27, 2013 12:26 PM
     
      Has Code
    Hi,
    In your code:

    Get-SCOMClass -Name "Microsoft.SystemCenter.HealthServiceWatcher" | Get-SCOMClassInstance | where { $_.DisplayName -eq $serverName } | foreach { $_.StopMaintenanceMode( [DateTime]::UtcNow, "OneLevel") }

    The parameter $serverName is a list of servers or just one server?

    Thanks
  • Wednesday, February 27, 2013 2:13 PM
     
      Has Code

    $serverName is just one. If you had an array of server names $serverNameArray you could change the 'where' command to:

    where { $serverNameArray -contains $_.DisplayName }


    Richard Benwell www.squaredup.com

  • Wednesday, February 27, 2013 2:35 PM
     
     

    Hi Thanks!

    I was trying to do that on my own buti didn't know what was the right command..

    is there a manual for PowerShell commands? somewhere i can actually learn how to write SCOM Commands in powershell?

    Thanks for all you help!

  • Wednesday, February 27, 2013 3:04 PM
     
     

    No problem!

    There are loads of resources for learning PowerShell, from the official TechNet site:

    http://technet.microsoft.com/en-gb/scriptcenter/powershell.aspx

    to community site and books:

    http://stackoverflow.com/questions/496234/what-tutorial-do-you-recommend-for-learning-powershell

    The TechNet documentation for SCOM PowerShell is here:

    http://technet.microsoft.com/en-us/library/hh920227.aspx

    And you'll find plenty of SCOM PowerShell examples in this forum, on www.systemcentercentral.com and on blogs. Be aware that the cmdlets have changed between SCOM 2007 R2 and 2012, so some examples you find might need updating for 2012. See http://technet.microsoft.com/en-us/library/hh914174.aspx

    The books on SCOM (e.g. 'Mastering System Center 2012 Operations Manager' or 'System Center 2012 Operations Manager Unleashed') also have examples.

    Good luck!


    Richard Benwell www.squaredup.com

  • Sunday, March 03, 2013 1:39 PM
     
     

    Hi again :)

    I put a group of computers in maintenance mode (using the command you wrote above)

    After a few minutes in maintenance mode the Agents state of the health service watcher changed their color to gray, Is that normal?

    Thanks!


    • Edited by dorlm Sunday, March 03, 2013 1:41 PM
    •