Put servers in Maintenance Mode in SCOM 2012

Hi,
When we put a server in maintenance mode in SCOM 2012 it asks for only the end time. How can we specify the start time for maintenance mode.
Thanks

You can specify the start time for maintenance mode by schedule Maintenance mode.
For how to create schedule for maintenance mode, you can refer below link
http://support.microsoft.com/kb/2704170/en-us
Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer"
Mai Ali | My blog: Technical

Similar Messages

  • How to place multiple servers in Maintenance Mode in SCOM 2012

    Hi All,
    I am trying to place multiple servers in Maintenance Mode in SCOM 2012 but i could not find any PoSh script or any other solution to do it.
    Could someone help me please?
    Regards, Srini

    Hi,
    Please find the script.
    need to have access and you can provide list of servers in text file.
     param([int32]$TimeMin, [string]$Reason, [string]$Comment)
                    $api = new-object -comObject 'MOM.ScriptAPI'
                    Import-Module operationsmanager
                    New-SCOMManagementGroupConnection
                    $Servers = Get-Content "ServerList.txt"
                    $Time = (Get-Date).Addminutes($TimeMin)
                    Foreach ($Server in $Servers)
                                    #Get Computer instance
                                    $ComputerClass = Get-SCOMClass -Name Microsoft.Windows.Computer
                                    $ComputerClassInstance = Get-SCOMClassInstance  -Class $ComputerClass | Where {$_.DisplayName -eq $Server}
                                    If ($ComputerClassInstance.InMaintenanceMode -eq $true)
                                    #Write-Host $Server " is in maintenance mode"
                                    Write-Host $Server" already under Maintenance Mode or not accessible by SCOM, skipped from script execution" -foregroundcolor "red"
                                    $api.LogScriptEvent('MaintenanceModeScript.ps1', 201, 1, "$Server already found under MM, skipped from script execution")
                                    Else
                                    #Write-Host $Server " is NOT in maintenance mode, attempting to put in MM......."
                                    If ($ComputerClassInstance -ne $Null)
                                                    $HealthServiceWatcherClass = Get-SCOMClass -name:Microsoft.SystemCenter.HealthServiceWatcher
                                                    #Get Health Service Watcher Class instance of the server
                                                    $HSWClass = Get-SCOMClass -Name Microsoft.SystemCenter.HealthServiceWatcher
                                                    $HSWClassIns = Get-SCOMClassInstance  -Class $HSWClass | Where {$_.DisplayName -eq $Server}
                                                    #Starting the maintenance mode
                                                    Start-SCOMMaintenanceMode -Instance $HSWClassIns -EndTime $Time -Reason $Reason -Comment
    $Comment
                                                    Start-SCOMMaintenanceMode -Instance $ComputerClassInstance -EndTime $Time  -Reason $Reason
    -Comment $Comment
                                                    Write-Host "Health Service Watcher and Agent server "$Server " kept in maintenance
    mode for $TimeMin minutes"  -foregroundcolor "green"
                                                    $api.LogScriptEvent('MaintenanceModeScript.ps1', 200, 0, "$Server kept in maintenance
    mode for $TimeMin minutes")
                                    Else
                                                    Write-Host $Server" not found in Domain" -foregroundcolor "red"
                                                    $api.LogScriptEvent('MaintenanceModeScript.ps1', 202, 1, "$Server not found in domain")
    Regards
    sridhar v

  • Script for putting servers under Maintiance mode in SCOM 2012

    Hi,
    Could someone pls help me out for putting windows servers under maintiance mode by using poweshell script. We have nearly 300 windows servers and needs to be put in maintiance mode as there was a scheduled activity. We are using scom2012 server.  I
    have gone through other sites and see some poweshell scripts. As am not good in scripting, pls help me out
    Regards, Rajeev Parambil

    Hi,
    Hope the below links can be useful for you:
    SCOM maintenance mode setting for list of servers
    http://blogs.technet.com/b/markmanty/archive/2012/05/14/scom-maintenance-mode-setting-for-list-of-servers.aspx
    Put Agents in Maintenance Mode using Remoting Powershell
    http://social.technet.microsoft.com/Forums/systemcenter/en-US/2171ef8f-4a7f-4ec0-8d35-d5a903884dff/put-agents-in-maintenance-mode-using-remoting-powershell-?forum=operationsmanagergeneral
    Regards,
    Yan Li
    Regards, Yan Li

  • How to schedule Maintenance Mode in SCOM 2012?

    Hi
    How do I schedule Maintenance Mode in SCOM 2012? Do we have any tool for 2012 like we had with 2007?
    Regards,
    Akhilesh
    Thanks, Akhilesh

    Yep - to add a calendar takes some extra steps:
    E.g. 
    1) Create a database which includes a table to store information such as:
    - target for maintenance mode
    - scheduled time for maintenance mode
    - Comments
    - Duration
    - Reason
    2) The Service Request fires off an Orchestrator runbook that stores this information in the database
    3) Another Runbook that runs frequently that checks the database to see if it should kick off maintenance mode.
    It isn't any easy solution for maintenance mode. It works better for more simplistic scheduling e.g. we do implement this kind of logic for environment refreshes and backups where we use the SM Portal and Orchestrator to log a date and then have another
    runbook that runs at 2am every day to check if it should execute a backup \ refresh.  
    Cheers
    Graham
    Regards Graham New System Center 2012 Blog! -
    http://www.systemcentersolutions.co.uk
    View OpsMgr tips and tricks at
    http://systemcentersolutions.wordpress.com/

  • Looking for a Powershell Script which can put the scom servers in maintenance mode

    Looking for a Powershell Script which can put the scom servers in maintenance mode so that SCOM should not send an alert during planned task.
    Rahul

    1. Provide list of servers line-by-line in C:\ServerList.txt, make sure you provide limited no. of servers, do not exceed 20 - 25 per batch
    2. Save the script with suitable name (test.ps1)
    3. Open PowerShell cmd prompt
    4. Script accepts 3 params - TimeInMinutes, Reason and Comment
    **** Please note, this script will work for SCOM 2012 R2
    param([int32]$TimeMin, [string]$Reason, [string]$Comment)
    try
    $api = new-object -comObject 'MOM.ScriptAPI'
    Import-Module operationsmanager
    New-SCOMManagementGroupConnection
    $Servers = Get-Content "C:\ServerList.txt"
    $Time = (Get-Date).Addminutes($TimeMin)
    Foreach ($Server in $Servers)
    #Get Computer instance
    $ComputerClass = Get-SCOMClass -Name Microsoft.Windows.Computer
    $ComputerClassInstance = Get-SCOMClassInstance  -Class $ComputerClass | Where {$_.DisplayName -eq $Server}
    If ($ComputerClassInstance -ne $Null)
    $HealthServiceWatcherClass = Get-SCOMClass -name:Microsoft.SystemCenter.HealthServiceWatcher
    #Get Health Service Watcher Class instance of the server
    $HSWClass = Get-SCOMClass -Name Microsoft.SystemCenter.HealthServiceWatcher
    $HSWClassIns = Get-SCOMClassInstance  -Class $HSWClass | Where {$_.DisplayName -eq $Server}
    #Starting the maintenance mode
    Start-SCOMMaintenanceMode -Instance $HSWClassIns -EndTime $Time -Reason $Reason -Comment $Comment
    Start-SCOMMaintenanceMode -Instance $ComputerClassInstance -EndTime $Time  -Reason $Reason -Comment $Comment
    Write-Host "Health Service Watcher and Agent server "$Server " kept in maintenance mode"  -foregroundcolor "green"
    $api.LogScriptEvent('MaintenanceModeScript.ps1', 200, 0, "$Server kept in maintenance mode for $TimeMin minutes")
    Else
    Write-Host $Server" not found " -foregroundcolor "red"
    $api.LogScriptEvent('MaintenanceModeScript.ps1', 201, 1, "$Server could not be found in domain")
    Catch [system.exception]
    $api.LogScriptEvent('MaintenanceModeScript.ps1', 201, 1, $_.Exception.Message)
    Faizan

  • SQL Query for maintenance mode in SCOM

    Hi all
    I was wondering if I can find a query about this request:
    - Found all the Servers that were restart without the maintenance mode were actived ?
    It's to make a Report To include in Reporting Services.
    sorry for my English :)
    Thank you very much and have a good day

    Your question seems related to SCOM. SCOM may use SQL Server, but to answer the question, I guess one needs to know SCOM, so maybe you should try a forum for that product? I found
    http://social.technet.microsoft.com/Forums/systemcenter/en-US/home?forum=operationsmanagergeneral
    Erland Sommarskog, SQL Server MVP, [email protected]

  • SCOM 2012 - Use Powershell to put specific server and contained objects into Maintenance Mode

    I am still trying to develop what I thought was going to be an easy script, to put a specific server and all it's contained objects into maintenance mode in SCOM 2012.   Not a group, but just one specific server and all it's stuff.
    My script to START maintenance mode has two parameters:
    1.  The FQDN.  So for example: server1.contoso.com
    2.  The amount of minutes to put into maintenance mode
    Then it does the following to START maintenance mode:
    Import-Module OperationsManager
    $Instance = Get-SCOMClassInstance -Name $FQDN
    If ($Instance)
    $newEnd = ((Get-Date).AddMinutes($minutes))
    Start-SCOMMaintenanceMode -Instance $Instance -end $newEnd -Reason "PlannedOther" -Comment "Comments here"
    This seems to work from what I can tell.  I know that when you schedule maintenance mode manually in SCOM, there is an option to apply to "Selected objects and all their contained objects".  I do not know if that is occurring based on
    my code above.   But I think that is what I want to happen.   I just want all monitoring and alerting for the specified server to stop.   So if you think I need to change the above code so that it gets all the "contained
    objects" please let me know.
    The second part, which I know for a fact isn't fully working, is intended to stop maintenance mode for a server.
    My script to STOP maintenance mode has only one parameter:
    1.  The FQDN.  So for example: server1.contoso.com
    Then it does the following to STOP maintenance mode:
    Import-Module OperationsManager
    $Instance = Get-SCOMClassInstance -Name $FQDN
    If ($Instance)
    $MMEntry = Get-SCOMMaintenanceMode -Instance $Instance
    If ($MMentry)
    #basically sends an end time of 1 minute from when the script is run
    $newEnd = ((Get-Date).AddMinutes(1))
    Set-SCOMMaintenanceMode -MaintenanceModeEntry $MMEntry -EndTime $NewEnd -Comment "Removing from Maintenance Mode"
    This part does seem to work partially.   It does remove the server from maintenance mode.  However, I suspect that it's not removing all the "contained objects" from maintenance mode because when I run the script to stop maintenance
    mode on a server, the little maintenance mode icon in SCOM does go away but the overall light for the server stays set to "Not Monitored".   It never turns back to the green checkbox and says "Healthy".   When I start
    and stop maintenance mode manually I can see that the green Healthy checkbox comes back.  But when I try to run my above code to do it via script, it stays at "Not Monitored" instead.
    Can someone help me out here?  Looking for answers to two questions:
    1.  Does my Start maintenance mode code look ok? Will that put a server and all it's contained objects into maintenance mode?
    2.  What do I need to hadd to my Stop maintenance mode code, so that it correctly stops maintenance mode on the server and all its objects and everything starts to be monitored again?
    Thanks in advance!  Please let me know if you need any more information in order to be able to help me!

    Hello, thanks for your response.  Unfortunately, it does not appear that the link you provided works.
    As far as not including "selected objects and all their contained objects" I am wondering if there is a way for me to tell for sure. One thing I found was that if I run this script and put the server into maintenance mode, then I go into
    SCOM and click on Edit Maintenance Mode for that server, it shows me the details.   It has some comment, and my selected reason, based on the code I posted above.   It also DOES have "selected objects and all their contained objects"
    selected at top.  So it seems to me like it is working correctly, and does contain all the objects.   If you think that 'Edit' screen would be inaccurate for some reason, please let me know.  Or if you know of a way for me to check and
    confirm, please let me know that as well.
    As for REMOVING it from maintenance mode, I did eventually find a line of code that I think works.  Here's what my code looks like now:
    Import-Module OperationsManager
    $Instance = Get-SCOMClassInstance -Name $FQDN
    If ($Instance)
    $MMEntry = Get-SCOMMaintenanceMode -Instance $Instance If ($MMentry)
    $Instance.StopMaintenanceMode([DateTime]::Now.ToUniversalTime(),[Microsoft.EnterpriseManagement.Common.TraversalDepth]::Recursive);
    When I use the above code to STOP maintenance mode, the green checkmark does reappear for the server, and everything seems to be being monitored again.   Unlike before, where the maintenance mode icon would go away, but it would never change back
    to saying 'Monitored' again.  So I think that changing that one line to stop maintenance mode seems to have done the trick.
    So I guess my last concern now is just putting in maintenance mode initially, as I was talking about above.  If you still think the 'Edit Maintenance Mode' screen is not a good indicator of what my code does, please let me know.

  • Automatic Maintenance Mode SCOM 2012

    What I'm trying to do is get an alert based on a shutdown event to trigger a script that then puts the server into maintenance mode.  I've seen a few solutions to this for 2007, but this is the only one I've seen for 2012. 
    https://overcast.azurewebsites.net/2013/11/auto-maintenance-mode-with-scom-2012/
    Basically, an alert is set up to watch for the shutdown event, which then uses a command channel to execute the script.  The main significant part of that is the use of the ManagedEntityDisplayName parameter in the command channel to pass the server
    name to the script.  If I run the script from a command prompt and pass the FQDN of the server to it as a parameter, it works like a charm.  But when I use SCOM to run it through the command channel, the server never gets put into
    mm.  For troubleshooting, I had it write a couple things to a log file. 
    When I run it from the command prompt, the log file contains the hostname I'm passing it for the ManagedEntity parameter in line 4, and the Instance that is returned from line 6 and it all works.
    When I run it with the command channel in SCOM, it again writes out the ManagedEntity parameter as the hostname, so that part seems to work the same.  But the Instance is returned to the log file as an empty line and then of course the server doesn't
    go into MM.  So it seems like something is different between me passing the FQDN as a parameter from the command line, and the command channel passing the ManagedEntity parameter from SCOM.  Even though they both get written to the log file as the
    hostname of the server.  Any idea what I'm missing?
    Param($ManagedEntityDisplayName)
    $startTime = [DateTime]::Now
    $endTime = $startTime.AddMinutes(15)
    "Managed Entity is $managedentitydisplayname" |out-file log.txt
    import-module OperationsManager
    $Instance = Get-SCOMClassInstance -Name $ManagedEntityDisplayName
    "Instance is $Instance" | Out-File log.txt -Append
    Start-SCOMMaintenanceMode -Instance $Instance -EndTime $endTime

    Hi 
    What version of Power shell are you using on your management server? The I suspect the issue might be that when you run it doesn't actually load "import-module
    OperationsManager" when scom runs it. So when you execute any scom command and save it into a variable it will always be empty.
    To test if this is the issue run this
    Param($ManagedEntityDisplayName)
    $startTime = [DateTime]::Now
    $endTime = $startTime.AddMinutes(15)
    "Managed Entity is $managedentitydisplayname" |out-file log.txt
    import-module OperationsManager
    $SCOMConnection = Get-SCOMManagementGroupConnection
    "Connection is $SCOMConnection" | Out-File log.txt -Append
    $SCOMAgent = Get-SCOMAgent -name $ManagedEntityDisplayName
    "SCOMAgent is $SCOMAgent" | Out-File log.txt -Append
    If you don't get anything for these variables looks like the Import module is the issue.
    I suggest the following:
    Adding the full file path location to the module (might just not be registered correctly)
    see: http://msdn.microsoft.com/en-us/library/dd878350(v=vs.85).aspx
    If the above doesn't fix the issue re installing the console might be needed
    see: http://thoughtsonopsmgr.blogspot.com.au/2013/02/om12-sp1-operations-manager-shell-fails.html
    What version of Power shell are you also running on your Management server/s? If you are running v4 you might also need to include credentials when making a connection to the management server:
    see: http://blogs.technet.com/b/robcost/archive/2008/05/01/powershell-tip-storing-and-using-password-credentials.aspx
    So your after you import the Operations manager module you need
    New-SCOMManagementGroupConnection -ComputerName "localhost" -Credential (Get-Credential WOODGROVE\Administrator)
    see: http://technet.microsoft.com/en-us/library/hh920188(v=sc.20).aspx
    Also how many management servers do you have? If you have more that 1 don't forget to place a copy of the script in the same location on each MS.
    Thanks Martin
    sustaslog.wordpress.com

  • SCCM 2012 Software Update Management for Windows Servers and how to automatic set SCOM maintenance mode?

    Hi,
    We planning to go one level higher to automat and have more dynamic Software Update Management for Windows Servers. We have SCCM 2012 R2, SCOM 2012 R2 and SCO 2012 R2.
    Our plan is to pur server in an AD-Group to get Update Schedule, from the servers will be importet to an Collection for Automatic Update and reboot. If I understand Everything right SCOM can't read AD-Group and put then in an Schedule maintenance mode. SCOM
    can read reg value as exempel.
    IS there any smar way to make the SCOM Maintenance Mode Schedule dynamic?
    I found this
    http://www.scom2k7.com/scom-2012-maintenance-mode-scheduler/?
    /SaiTech

    You could use Orchestrator to put the servers from a specific collection, or AD group, in maintenance mode in SCOM. For an example see:
    http://www.systemcentercentral.com/orchestrator-how-to-scom-maintenance-mode-for-windows-computers-in-an-sccm-collection/
    My Blog: http://www.petervanderwoude.nl/
    Follow me on twitter: pvanderwoude

  • SCOM 2012 Maintenance Mode PowerShell Script Problems

    I've seen other questions about this topic before, but none of them seem to address my specific problem, so I am starting a new thread.
    I am writing a script to put a single server (not a group) into maintenance mode.   Here is the command that it ultimately tries to call:
     Start-SCOMMaintenanceMode-Instance$Instance-EndTime$EndTime-Reason$Reason-Comment$Comment     
    So an exmaple would look like this:
    Start-SCOMMaintenanceMode -Instance "$Instance -EndTime "02/03/2014 15:26:00" -Reason "PlannedOther" -Comment "Testing Maintenance Mode"
    When my script tries to run this command, this is the error message that I get:
    Start-SCOMMaintenanceMode : Start time must be before end time for maintenance mode.
    Parameter name: startTime
    At C:\users\x036036\Desktop\Start-SCOMMaintenanceModeForServer.ps1:143 char:21
    +                     Start-SCOMMaintenanceMode -Instance $Instance -EndTime $EndT ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (Microsoft.Syste...anceModeCommand:StartSCMaintenanceModeCommand) [Start-SCOMMaintenance
       Mode], ArgumentOutOfRangeException
        + FullyQualifiedErrorId : ExecutionError,Microsoft.SystemCenter.OperationsManagerV10.Commands.StartSCMaintenanceModeCommand
    I've tried to look at Start-SCOMMaintenanceMode help online, but I don't see that "startTime" is a parameter.  So what is this error message talking about?  What am I missing?  

    Thanks for your help.   I didn't see your response until just now, but I have been playing around with this all since my last response.   I got it to work.  I wish I could pinpoint what exactly I changed to get it to work, but I
    feel like I've been changing so much stuff that I'm not sure any more.
    Just in case anyone finds it useful, here is the code.
    [CmdletBinding(SupportsShouldProcess=$true)]
    param
    [Parameter(Mandatory=$True,
    ValueFromPipeline=$True,
    ValueFromPipelineByPropertyName=$True,
    HelpMessage='What is the server you want to put in Maintenance Mode?')]
    [Alias("Server")]
    [string[]]$ServerName,
    [Parameter(Mandatory=$True,
    ValueFromPipeline=$false,
    ValueFromPipelineByPropertyName=$True,
    HelpMessage='Specifies the time the maintenance will end. The minimum amount of time a resource can be in maintenance mode is 5 minutes. This is a required parameter. Format is 1/29/2014 8:59:26 AM')]
    [Datetime]$end,
    [Parameter(Mandatory=$False,
    ValueFromPipeline=$True,
    ValueFromPipelineByPropertyName=$True,
    HelpMessage='PlannedOther, UnplannedOther, PlannedHardwareMaintenance, UnplannedHardwareMaintenance, PlannedHardwareInstallation, UnplannedHardwareInstallation, PlannedOperatingSystemReconfiguration, UnplannedOperatingSystemReconfiguration, PlannedApplicationMaintenance, ApplicationInstallation, ApplicationUnresponsive, ApplicationUnstable, SecurityIssue, LossOfNetworkConnectivity')]
    [string]$Reason,
    [Parameter(Mandatory=$False,
    ValueFromPipeline=$True,
    ValueFromPipelineByPropertyName=$True,
    HelpMessage='Allows you to type a comment about the maintenance activity.')]
    [string]$Comment,
    [switch]$EventLog
    set-strictmode -version latest
    #$start=Get-Date
    #$currentlog = $start.ToString()
    Write-Verbose "Starting $($myinvocation.mycommand)"
    Write-Verbose "Ready to put ServerName $ServerName in Maintenance Mode"
    Function Start-SCOMMaintenanceModeForServer
    [CmdletBinding(SupportsShouldProcess=$true)]
    param
    [Parameter(Mandatory=$True,
    ValueFromPipeline=$True,
    ValueFromPipelineByPropertyName=$True,
    HelpMessage='What is the server you want to put in Maintenance Mode?')]
    [Alias("Server")]
    [string[]]$ServerName,
    [Parameter(Mandatory=$True,
    ValueFromPipeline=$false,
    ValueFromPipelineByPropertyName=$True,
    HelpMessage='Specifies the time the maintenance will end. The minimum amount of time a resource can be in maintenance mode is 5 minutes. This is a required parameter. Format is 1/29/2014 8:59:26 AM')]
    [Datetime]$end,
    [Parameter(Mandatory=$False,
    ValueFromPipeline=$True,
    ValueFromPipelineByPropertyName=$True,
    HelpMessage='PlannedOther, UnplannedOther, PlannedHardwareMaintenance, UnplannedHardwareMaintenance, PlannedHardwareInstallation, UnplannedHardwareInstallation, PlannedOperatingSystemReconfiguration, UnplannedOperatingSystemReconfiguration, PlannedApplicationMaintenance, ApplicationInstallation, ApplicationUnresponsive, ApplicationUnstable, SecurityIssue, LossOfNetworkConnectivity')]
    [string]$Reason,
    [Parameter(Mandatory=$False,
    ValueFromPipeline=$True,
    ValueFromPipelineByPropertyName=$True,
    HelpMessage='Allows you to type a comment about the maintenance activity.')]
    [string]$Comment,
    [switch]$EventLog
    Begin
    Write-Verbose "Starting Function Start-SCOMMaintenanceModeForServer"
    #Check for minumum Maintenance mode period of 5 mins.
    $start = Get-Date
    $5MinFromNowTime = $start.AddMinutes(5)
    #$end = [datetime]$end
    $end = $end.AddSeconds(5)
    if($end -lt $5MinFromNowTime)
    Write-Error "The time span for the maintenance mode should be at least 5 minutes." -ErrorAction Stop
    Write-Verbose "Following server will be put in Maintenance Mode: $ServerName"
    $MSs = Get-SCOMManagementServer
    } #End Begin
    Process
    Write-Verbose "Checking if server $ServerName is a Management Server"
    #Write-Verbose ($MSs | Select DisplayName)
    if(($MSs | Select DisplayName) -eq $ServerName)
    Write-Verbose "We don't want to put a Management Server in Maintenance Mode. Skipping"
    else
    Write-Verbose "Let's put server $ServerName in Maintenance Mode"
    $Instance = Get-SCOMClassInstance -Name $ServerName
    if ($PSCmdlet.ShouldProcess("Putting $ServerName in Maintenance Mode until $($end).") )
    Write-Verbose ("Start-SCOMMaintenanceMode -Instance " + $Instance + " -EndTime " + $end + " -Reason " + $Reason + " -Comment " + $Comment)
    Start-SCOMMaintenanceMode -Instance $Instance -end $end -Reason $Reason -Comment $Comment
    }#End of whatif
    }#End of else
    if ($PSBoundParameters['EventLog'])
    write-eventlog -LogName "Operations Manager" -Source "OpsMgr SDK Service" -EventID 999 -message "The following Objects are put into in Maintenance Mode until $($end) : $($ServerName)"
    }#End if
    } #End Process
    End
    Write-Verbose "Finished Function Start-SCOMMaintenanceModeForServer Function"
    #Main
    try
    if ($PSBoundParameters['EventLog'])
    write-eventlog -LogName "Operations Manager" -Source "OpsMgr SDK Service" -EventID 998 -message "The $($myinvocation.mycommand) is used to put Objects in Maintenance Mode"
    Write-Verbose "Checking if OperationsManager Module is loaded"
    #Check if OperationsManager Module is loaded.
    if(!(Get-Module OperationsManager))
    Write-Verbose "Importing OperationsManager Module"
    Import-Module OperationsManager -ErrorAction Stop
    Write-Verbose "Checking for OM2012 environment"
    #Check if OM2012 is being used.
    if(!(Get-Module OperationsManager).Description -eq "Operations Manager OperationsManagerV10 Module")
    Write-Error "This script is only for OM2012"
    #Call Function
    if ($PSBoundParameters['EventLog'])
    Start-SCOMMaintenanceModeForServer -ServerName $ServerName -end $end -Reason $Reason -Comment $Comment -EventLog
    else
    Start-SCOMMaintenanceModeForServer -ServerName $ServerName -end $end -Reason $Reason -Comment $Comment
    } #End Try
    catch [System.IO.FileNotFoundException]
    "OperationsManager Module not found"
    $_.Exception.Message
    catch
    Write-Warning "Oops something went wrong"
    $_.Exception.Message
    $end=Get-Date
    Write-Debug ("Total processing time {0}" -f ($end-$start).ToString())
    Write-Verbose "Ending $($myinvocation.mycommand)"
    There is one remaining problem with this script.   It does not correctly check to see if something is a management server. We have two management servers. These are the applicable lines, which I still haven't gotten to work yet. First, this retrieves
    the list of my Management servers:
    $MSs=Get-SCOMManagementServer     
    Next, these lines are supposed to check if the server I specified is a management server:
    if(($MSs | Select DisplayName) -eq $ServerName)
    Write-Verbose "We don't want to put a Management Server in Maintenance Mode. Skipping"
    Thanks to the Intellisense pop-up deal, I can see that $MSs does get my two management servers. And I can clearly see that there is a DisplayName column. And I can also see that the $ServerName does match what I put in my command line.   But it doesn't
    seem to catch them if they are actually equal to each other. I don't know if it's because there's two Management Servers, and it doesn't know how to compare like that? Any idea? Is there some sort of loop I need to write so that it compares is to the DisplayName
    for EACH Management Server it finds? Any help would be greatly appreciated.

  • Maintainence Mode script for SCOM 2012

     Hi All
     Currently we use PowerShell script to place servers in maintenance mode (SCOM 2007 ). While executing the script we specify a text file which contains list of agents.
     Am looking for same type of script which can work for SCOM 2012. After searching I got the MM tool for placing agent or group in Maintenance. Instead I would need the script to get agents from text file. Also it should check if agent is part of
    cluster and place related cluster also in MM.
    Let me know , if any one can help me here.
    Regards
    Madhavi

    Hi,
    The below two links should be helpful for you, please go through them:
    SCOM 2012: Put Cluster Node and Cluster Object in Maintenance Mode
    OpsMgr 2012: Group Maintenance Mode via PowerShell (the way it should be)
    http://www.systemcentercentral.com/opsmgr-2012-group-maintenance-mode-via-powershell-the-way-it-should-be/
    Please Note: Since site is not hosted by Microsoft, the link may change without notice. Microsoft does 
    not guarantee the accuracy of this information the web.
    Regards,
    Yan Li
    Regards, Yan Li

  • Another SCOM Maintenance Mode query/advice...

    Hi,
    Just looking some advice on setting SCOM Maintenance Mode (using SCOM/SCO 2012R2)...
    I want to be able to set a server entirely into MaintMode, ie similar to choosing "Selected object AND ALL their contained objects" from SCOM console.
    I had asked similar question back in SCOM 2007/Opalis days, but the solution then (placing server and health server watchers separately into maintenance as per Anders blog http://contoso.se/blog/?p=2164 I'm not sure is appropriate now as I believe MaintMode
    is handled differently in 2012.
    I have seen some pretty complex solutions where using custom built DBs to hold MaintMode status etc.  Was hoping theres a neater/simpler soultion using the Orchestrator Activities these days.
    If not possible using Native Orchestrator then the fallback would be to try use powershell commandlet.  Looking at the Commandlet Examples if I used the following example solution, will that effectively put the server object (and all contained objects
    into maintenance which is what I'm trying to achieve.
    Windows PowerShell
    PS C:\> $Instance = Get-SCOMClassInstance -Name "Server01.Contoso.com"
    PS C:\> $Time = ((Get-Date).AddMinutes(10))
    PS C:\> Start-SCOMMaintenanceMode -Instance $Instance -EndTime $Time -Comment "Applyin
    Any advice to this recurring pain point of SCOM much appreciated.
    PS. Not sure if this post is better placed here or in SCOM/Powershell forum so can move if necessary...

    Hi Michael,
    thanks for your reply confirming the powershell command will work.
    I have actually just tried using the native Start Maintenance Mode Activity which actually seems to do as required - if the monitor selected is the relevant <servername> : Microsoft.Windows.Computer: <servername> object then it seems to put the
    entire server into maintenance.  I tested against a server which happened to also host SQL role, so when I placed in Maint via the runbook  I then stopped the SQL service and no alerts generated from SQL MP and I could see the spanner Icon against
    the server in relevant SQL node views aswell.
    I had though maybe that only windows MP stuff might be supressed - so again when I came across all the very complex solutions to apply Maint mode properly I wasnt sure if it was still relevant in 2012 (even though some of those solutions indicated for use
    on SCOM/SCO 2012?)
    Anyway if the simple solution work - as it appears to do so, then I'll run with that - unless someone can tell me why not?...
    Cheers

  • Exch2k13 - to apply spks or CU should I put the server on 'Maintenance Mode'

    Hi,
    Since we have only one server acting as CAS/MBX, should I put it on 'maintenance mode' before apply spk/cu?

    Hi,
    Maintenance mode should be used with Mailbox servers, both standalone mailbox servers and multi-role servers.
    Here is a related blog which can help for your reference.
    Exchange 2013 Maintenance mode
    http://blogs.technet.com/b/nawar/archive/2014/03/30/exchange-2013-maintenance-mode.aspx
    Best regards,
    Belinda
    Belinda Ma
    TechNet Community Support

  • SCOM 2012 monitoring IIS - windows updates generate SCOM alerts

    We are using SCOM 2012 to monitor our environment. There is a logic implemented to suppress alerts (using maintenance mode) when Windows Updates cause system reboot.
    We followed:<o:p></o:p>
    http://operatingquadrant.com/2009/08/15/scom-automatically-starting-maintenance-mode-when-servers-are-rebooted-for-patching/<o:p></o:p>
    Basically when in system event log event id 1074 appears then system is put in Maintenance mode. There is a problem with some IIS web servers - they
    generate a lot of alerts when Windows Updates are installed (e.g. Microsoft Windows Internet Information Services 2003 Application Pool is Unavailable)
    and before windows reboot. In details:
    5:08 AM - Windows update installation in event log (event id 19)e.g. 
    Installation Successful: Windows successfully installed the following update: Security Update for Microsoft .NET Framework 4 on Windows Server 2003, Vista, Windows 7, Server 2008 x86 (KB2972106)
    5:09 AM - SCOM generates alerts: Microsoft Windows Internet Information Services 2003 Application Pool is Unavailable
    5:17 AM - event id 1074: The process winlogon.exe has initiated the restart of computer. SCOM put this server in Maintenance mode.
    After 5:17 AM no more alerts generated by SCOM 
    We cannot change our logic and put system in maintenance mode based on event ID 19 (windows update installation) because there are a
    lot of event ID 19 events generated almost every day. So we do not want to put our server in maintenance mode each time when windows updates are installed. Just when windows update installation cause some IIS features stops. Any idea?

    For issue 1074, You can refer below link
    http://theitcrownd.blogspot.com/2012/01/set-up-automatatic-scom-maintenance.html
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer"
    Mai Ali | My blog: Technical | Twitter:
    Mai Ali

  • Getting 34208 Events in IIS server after come out from Maintenance mode

    Hi Experts,
    We are monitoring .Net application(APM) in our environment(SCOM 2012 SP1).  We are putting all the servers in Maintenance mode on every sunday(Weekly Maintenance), after come out from MMode  getting 34208 events in OPSMGR Logs, particularly from
    IIS servers(APM). 
    Do we have any fix for that like cumulative update?
    Can we put IIS server into Maintenance mode? If we put in MMode, Will it affect monitoring??
    Expecting your reply.. Thanks in advance!!!
    Regards
    Karthick

    Thanks for reply Agrawal!
    I know that we won't get alerts if the servers are in Maintenance mode.  But we are getting 34208 events particularly from IIS servers(.Net Application Performance Monitoring - APM) as the result we are receiving warning alerts in SCOM console stating
    that " Restart IIS service" which will affect other monitoring in the servers.
    Is anyone getting this issue in your environment?  Generally we will get 34208 events while we adding new application in to IIS server.  But here we are getting this events after the server come out from MMode.
    Kindly provide your valuable suggestions.  Thanks!
    Regards
    Karthick

Maybe you are looking for