Sunday, December 29, 2013

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 of the SharePoint content databases of all web applications by skipping 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.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:


  1. It's a cool feature. Thanks for sharing it.

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

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

    1. Its set based on "MaintenanceType" parameter. However, You can customize it further. E.g. You can't display any other message of your choice!


Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...