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( "MaintenancePlanned", $maintenanceStartDateTime, $maintenanceEndDateTime, $notificationStartDateTime, $notificationEndDateTime, $duration, "http://<SiteURL>/SitePages/MyMaintenanceDescription.aspx") $contentDB.MaintenanceWindows.Clear() $contentDB.MaintenanceWindows.Add($maintenanceWindow) $contentDB.Update()
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:
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>" $contentDB.MaintenanceWindows.Clear() $contentDB.Update()
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.