次の方法で共有


SharePoint 2013 Maintenance Window Notifications

SharePoint 2013 introduced a new class called SPMaintenanceWindow.  SPMaintenanceWindow encapsulates a maintenance window message you can post to end users at the content database level.  The maintenance window message is somewhat limited by the fact that you can not compose your own custom message on the status bar.  The functionality does allow you to do is set the start and end time (NotificationStartDate and NotificationEndDate) the message will be displayed to end users, as well as the start and end time (MaintenanceStartDate and MaintenanceEndDate) of the actual maintenance work, which is used to build the maintenance window text.  You can also, optionally, choose to provide a work duration and hyperlink to a location that could provide additional details.  To leverage the hyperlink capability, you must specify a duration.

To better understand the types of messages you can craft to users, below are samples of some of the different message options, and the corresponding PowerShell variables used to create the message.  The PowerShell code at the end of the page will leverage the sample variables and set the message on every content database in the SharePoint 2013 farm.

Single Day Maintenance Planned

image

 $maintenanceStartDate  = "9/28/2013 08:00:00 AM" # Date when the maintenance will start
$maintenanceEndDate    = "9/28/2013 02:00:00 PM" # Date when the maintenance will stop
$notificationStartDate = "9/23/2013 06:00:00 AM" # Date when the message will start being displayed
$notificationEndDate   = "9/28/2013 10: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          = 0   # duration days
$readOnlyHours         = 0   # duration hours. 
$readOnlyMinutes       = 0   # duration minutes only appears if days and minutes are both zero

Multi-day Maintenance Planned

image

 $maintenanceStartDate  = "9/27/2013 08:00:00 AM" # Date when the maintenance will start
$maintenanceEndDate    = "9/28/2013 02:00:00 PM" # Date when the maintenance will stop
$notificationStartDate = "9/23/2013 06:00:00 AM" # Date when the message will start being displayed
$notificationEndDate   = "9/28/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          = 0   # duration days
$readOnlyHours         = 0   # duration hours. 
$readOnlyMinutes       = 0   # duration minutes only appears if days and minutes are both zero

Single Day Maintenance Warning

image

 $maintenanceStartDate  = "9/27/2013 08:00:00 AM" # Date when the maintenance will start
$maintenanceEndDate    = "9/27/2013 02:00:00 PM" # Date when the maintenance will stop
$notificationStartDate = "9/23/2013 12:00:00 AM" # Date when the message will start being displayed
$notificationEndDate   = "9/27/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       = "MaintenanceWarning"    # OPTIONS ARE: MaintenancePlanned | MaintenanceWarning
$readOnlyDays          = 0   # duration days
$readOnlyHours         = 0   # duration hours. 
$readOnlyMinutes       = 0   # duration minutes only appears if days and minutes are both zero

Multi-day Maintenance Warning

image

 $maintenanceStartDate  = "9/27/2013 08:00:00 AM" # Date when the maintenance will start
$maintenanceEndDate    = "9/28/2013 02:00:00 PM" # Date when the maintenance will stop
$notificationStartDate = "9/23/2013 06:00:00 AM" # Date when the message will start being displayed
$notificationEndDate   = "9/28/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       = "MaintenanceWarning"    # OPTIONS ARE: MaintenancePlanned | MaintenanceWarning
$readOnlyDays          = 0   # duration days
$readOnlyHours         = 0   # duration hours. 
$readOnlyMinutes       = 0   # duration minutes only appears if days and minutes are both zero

Single Day Maintenance Warning With a Duration Greater Than Zero

image

 $maintenanceStartDate  = "9/28/2013 08:00:00 AM" # Date when the maintenance will start
$maintenanceEndDate    = "9/28/2013 02:00:00 PM" # Date when the maintenance will stop
$notificationStartDate = "9/23/2013 06:00:00 AM" # Date when the message will start being displayed
$notificationEndDate   = "9/28/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       = "MaintenanceWarning"    # 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

Single Day Maintenance Warning With a Duration Less Than Zero and a Hyperlink

image

 $maintenanceStartDate  = "9/28/2013 08:00:00 AM" # Date when the maintenance will start
$maintenanceEndDate    = "9/28/2013 02:00:00 PM" # Date when the maintenance will stop
$notificationStartDate = "9/23/2013 06:00:00 AM" # Date when the message will start being displayed
$notificationEndDate   = "9/28/2013 02:00:00 PM" # Date when the message will stop being displayed
$maintenanceLink       = "https://www.bing.com"   # This link will only appear if the maintenance duration is defined.
$maintenanceType       = "MaintenanceWarning"    # OPTIONS ARE: MaintenancePlanned | MaintenanceWarning
$readOnlyDays          = -1  # duration days
$readOnlyHours         = 0   # duration hours. 
$readOnlyMinutes       = 0   # duration minutes only appears if days and minutes are both zero

Single Day Maintenance Warning With a Duration Greater Than Zero and a Hyperlink

image

 $maintenanceStartDate  = "9/28/2013 08:00:00 AM" # Date when the maintenance will start
$maintenanceEndDate    = "9/28/2013 02:00:00 PM" # Date when the maintenance will stop
$notificationStartDate = "9/23/2013 06:00:00 AM" # Date when the message will start being displayed
$notificationEndDate   = "9/28/2013 02:00:00 PM" # Date when the message will stop being displayed
$maintenanceLink       = "https://www.bing.com"   # This link will only appear if the maintenance duration is defined.
$maintenanceType       = "MaintenanceWarning"    # 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

Multi-day Maintenance Warning with Duration Less Than Zero and a Hyperlink

image

 $maintenanceStartDate  = "9/28/2013 08:00:00 AM" # Date when the maintenance will start
$maintenanceEndDate    = "9/29/2013 10:00:00 PM" # Date when the maintenance will stop
$notificationStartDate = "9/23/2013 06:00:00 AM" # Date when the message will start being displayed
$notificationEndDate   = "9/29/2013 10:00:00 PM" # Date when the message will stop being displayed
$maintenanceLink       = "https://www.bing.com"   # This link will only appear if the maintenance duration is defined.
$maintenanceType       = "MaintenanceWarning"    # OPTIONS ARE: MaintenancePlanned | MaintenanceWarning
$readOnlyDays          = -1  # duration days
$readOnlyHours         = 0   # duration hours. 
$readOnlyMinutes       = 0   # duration minutes only appears if days and minutes are both zero

This PowerShell code leverages the variables used in the samples above to set the message on every content database in the farm.

 $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()
}

If you need to clear the maintenance window message queue, perhaps your maintenance window was cancelled, execute this PowerShell code.

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

Comments

  • Anonymous
    September 30, 2013
    That is awesome, I had no idea.  Thanks for sharing.

  • Anonymous
    September 30, 2013
    http://denledhanoi.com cung cap den led tai Viet Nam

  • Anonymous
    December 19, 2013
    http://www.dailydenled.com mang den cho ban giai phap tiet kiem dien

  • Anonymous
    December 19, 2013
    tks for help ! i like http://www.dailydenled.com

  • Anonymous
    April 15, 2014
    Nice! thi is what i'm looking for Thanks for your sharing! ........................................ LED lighting http://elek.vn

  • Anonymous
    August 13, 2014
    I wrote scripts that are working with this objects. You can select Content DB, Site,Web App or all content DBs on the farm. gallery.technet.microsoft.com/to-Add-Remove-and-Get-d4321b66

  • Anonymous
    October 08, 2014
    http://www.ledsieusang.com cung cap den led tai HCM

  • Anonymous
    November 28, 2014
    vào đây mua đèn led giá rẻ http://denled.hanoi.vn/

  • Anonymous
    January 02, 2015
    http://denledchieusang.com/ Cung cap den LED chieu sang chat luong cao tai Viet Nam

  • Anonymous
    January 12, 2015
    I have tested this and it works great. But I have one issue and that is that the date/time is not adjusting to time zones. The date/time that you set to your SPMaintenanceWindow object is shown to everyone, regardless of which time zone you're in. Is there a solution to this?

  • Anonymous
    March 19, 2015
    I try to post my comment... Why i alway get a notification: "your comment has been flaged as a spam"????

  • Anonymous
    March 19, 2015
    Thanks for sharing. I find the quality of your products

  • Anonymous
    May 25, 2015
    Thanks For Sharing. I'm Tien. I'm From Viet Nam My Website is http://tongdailapmangfpt.net/ Please comments

  • Anonymous
    May 26, 2015
    denchieusang.vn/.../206311.html chuyen cung cap den led am tran

  • Anonymous
    May 29, 2015
    Đèn led Kingled chuyên cung cấp đèn led chiếu sáng uy tín, chất lượng toàn quốc. Bảo hành 2 năm! http://kingled.vn/

  • Anonymous
    October 28, 2015
    I liked it. Thanks a lot. I have created a custom page in the Admin Panel which takes the values to be stored in the maintenance window. But I need to know where in the content database the maintenance window notifications are stored so that I can override. Second, requirement is I want only the logged in users should see the notifications.