SharePoint Maintenance Windows


I recently received an e-mail informing me of a planned SharePoint maintenance that was scheduled to take place over the weekend.  There’s certainly nothing wrong with sending an e-mail but I started to think about using SharePoint’s notification bar as an alternative.  I’m familiar with using JavaScript notification options but that’s not a great option for something like this so I started looking for a PowerShell alternative.  (I couldn’t remember if there was a PowerShell option or not but how could there not be?)

It turns out that there’s an SPMaintenanceWindow object that allows you to… *ahem* … set a SharePoint maintenance window and it takes just a few lines of PowerShell to accomplish this.

Add-PSSnapin Microsoft.SharePoint.Powershell

$contentDB = Get-SPContentDatabase -WebApplication "http://<SiteURL>"

$maintenanceStartDateTime = "08/30/2015 01:56:00 PM"

$maintenanceEndDateTime = "08/30/2015 01:58:00 PM"

$notificationStartDateTime = "08/30/2015 01:56:00 PM"

$notificationEndDateTime = "08/30/2015 01:58:00 PM"

$duration = 1

$maintenanceWindow = New-Object Microsoft.SharePoint.Administration.SPMaintenanceWindow(












A few notes:

If you clicked on the link above, you’ll see that there are 2 constructors.  One that accepts the parameters seen in this post and another that doesn’t accept any.  I had issues setting the dates when using the parameterless constructor… So I chose the path of least resistance.

The maintenance type options are:

  1. MaintenancePlanned
  2. MaintenanceWarning

You’ll see a different message depending on which option you choose.  You’ll also see a “More Information” link that redirects the user to the URL provided to the constructor if you in fact provide a URL.

If you need to remove the message, the following will do so:

$contentDB = Get-SPContentDatabase -WebApplication "http://<SiteURL>"



While sending an e-mail is a perfectly acceptable option, I would prefer using this method for several reasons.  For starters, if you need to change the maintenance schedule, you won’t have to send multiple e-mails to the company.  You also avoid sending multiple e-mails for silly typos in the message.