Friday, November 29, 2013

SharePoint 2013 Maintenance Notification

SharePoint 2013 contains a SPMaintenaceWindow class which can use to give notifications to end users scoped to SharePoint content database. This is a simple PowerShell script you need to execute.

Ex:-

Enable Notification

$maintenanceStartDate  = "11/29/2013 08:00:00 AM" # Date when the maintenance will start
$maintenanceEndDate    = "11/30/2013 02:00:00 PM" # Date when the maintenance will stop
$notificationStartDate = "11/28/2013 06:00:00 AM" # Date when the message will start being displayed
$notificationEndDate   = "11/30/2013 02:00:00 PM" # Date when the message will stop being displayed
$maintenanceLink       = ""                      # This link will only appear if the maintenance duration is defined.
$maintenanceType       = "MaintenancePlanned"    # OPTIONS ARE: MaintenancePlanned | MaintenanceWarning
$readOnlyDays          = 1   # duration days
$readOnlyHours         = 6   # duration hours. 
$readOnlyMinutes       = 0   # duration minutes only appears if days and minutes are both zero
 
$maintenanceWindow = New-Object Microsoft.SharePoint.Administration.SPMaintenanceWindow
$maintenanceWindow.MaintenanceEndDate    = $maintenanceEndDate
$maintenanceWindow.MaintenanceStartDate  = $maintenanceStartDate
$maintenanceWindow.NotificationEndDate   = $notificationEndDate
$maintenanceWindow.NotificationStartDate = $notificationStartDate
$maintenanceWindow.MaintenanceType       = $maintenanceType
$maintenanceWindow.Duration              = New-Object System.TimeSpan( $readOnlyDays, $readOnlyHours, $readOnlyMinutes, 0)
$maintenanceWindow.MaintenanceLink       = $maintenanceLink
 
Get-SPContentDatabase | % {
    $_.MaintenanceWindows.Clear()
    $_.MaintenanceWindows.Add($maintenanceWindow)
    $_.Update()
}

 


Disable Notification



Get-SPContentDatabase | % {
    $_.MaintenanceWindows.Clear()
    $_.MaintenanceWindows.Add($maintenanceWindow)
    $_.Update()
}

Reference: http://blogs.msdn.com/b/josrod/archive/2013/09/30/sharepoint-2013-maintenance-window-notifications.aspx

Post a Comment