SharePoint 2013 Maintenance Window Notifications

In continuation to my earlier post: Site Under Maintenance Page for SharePoint, while the solution serves the purpose perfectly by displaying a typical “Site under maintenance” page during occasions like SharePoint patching, upgrade, etc. wouldn’t it be nice to intimate end-users about the planned maintenance window in advance?

Well, SharePoint 2013 brings a new class SPMaintenanceWindow to support planned maintenance windows. Here is how it works: Prior to planned maintenance window schedules, You set the maintenance window on SharePoint content databases to display a notification to end users about the Planned maintenance window.

Once user hit SharePoint sites they’ll see a notification banner on SharePoint 2013 sites notification area (On Top).  Here is the PowerShell script to set maintenance window notification in SharePoint 2013:

How to Create SharePoint 2013 maintenance window notifications?

Add-PSSnapin Microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

$WebAppURL = ""

#Get all content databases of the web application 
$ContentDbs = Get-SPContentDatabase -WebApplication $WebAppURL

#Create maintenance Window Object
$MaintenanceWindow = New-Object Microsoft.SharePoint.Administration.SPMaintenanceWindow
$MaintenanceWindow.MaintenanceEndDate    = "12/31/2013 11:59:00 PM"
$MaintenanceWindow.MaintenanceStartDate  = "12/29/2013 12:00:00 AM"
$MaintenanceWindow.NotificationEndDate   = "12/31/2013 11:59:00 AM"
$MaintenanceWindow.NotificationStartDate = "12/25/2013 08:00:00 AM"
$MaintenanceWindow.MaintenanceType       = "MaintenancePlanned"  #Another Option: MaintenanceWarning
$MaintenanceWindow.Duration              = "03:00:00:00" #in "DD:HH:MM:SS" format
$MaintenanceWindow.MaintenanceLink       = ""

#Add Maintenance window for each content database of the web application
$ContentDbs | ForEach-Object  {
  #Clear any existing maintenance window
  #Add New Maintenance Window

The above script gets all content databases associated with the provided web application and sets the maintenance window for site collections residing on them. Here is the script in action:

Maintenance Windows in SharePoint 2013

You can get all the SharePoint content databases of all web applications by skipping the parameter -WebApplication in Get-SPContentDatabase cmdlet.

$ContentDbs = Get-SPContentDatabase

Once the maintenance window is completed, don’t forget to clear it!

Get-SPContentDatabase | foreach-object {

BTW, even though the banner says: Sites will be in Read-only mode, actually the script it self doesn’t set sites so. We’ve to make the site collections read-only explicitly, if needed.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

6 thoughts on “SharePoint 2013 Maintenance Window Notifications

  • We generally keep all databases but one offline for all webapps so that we have an idea of where no site collections are going to be created. Just realized that all of a webapps databases have to be started (ready) in order for the maintenance banner to work properly.

  • This post says you can’t customize the text, but there is an option to add in a link for more information.

    • are you saying yes or no?

    • Its set based on “MaintenanceType” parameter. However, You can’t customize it further. E.g. You can’t display any other message of your choice!

  • Can I customize the displayed text ? e.g. search not working correct?

  • It’s a cool feature. Thanks for sharing it.


Leave a Reply

Your email address will not be published. Required fields are marked *