App_Offline – Patch, maintain & troubleshoot your SharePoint portal with class

This is pretty slick- we can add a file called App_offline.htm into the root folder of a specific SharePoint web app, and it will have the effect of trumping all other pages and processes with that Web Application. It will simply render the contents of that HTML page.

Good for planned outages e.g. patching, CU’s etc.

I came across this script from MSDN which automates the process. It spins through all the Web Applications in a given SharePoint farm and plops the App_offline.htm in their root folder. When you’re done whatever maintenance window you’re involved in, it will remove. Neato.

Credit to Brendan Griffin over at MS!:
http://blogs.technet.com/b/fromthefield/archive/2014/07/04/sharepoint-maintenance.aspx

#Load SharePoint assembly
$Assemblies = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

#Check if the script is running on MOSS 2007
If (Test-Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12"){$Mode="2007"}

#Grab all Web Apps
$WebApps = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.WebApplications

#Retrieve Servers 
$Farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$SPServers = $Farm.Servers | Where {$_.Role -eq "Application"} | Foreach {$_.Name}

Foreach ($WebApp in $WebApps)
{
Foreach ($URL in $WebApp.AlternateUrls)
    {
    If ($Mode = "2007")
    {
    $WebRoot = ($WebApp.GetIisSettingsWithFallback($URL.URLZone)).Path.FullName -replace ":","$"
    }
    Else
    {
    $WebRoot = ($WebApp.GetIisSettingsWithFallback($URL.Zone)).Path.FullName -replace ":","$"
    }
    Write-Host "Setting the Holding Page for" $WebApp.Name "- Zone:" $Url.URLZone -ForegroundColor Green
    Foreach ($Server in $SPServers)
        {
        Write-Host "-Updating" $Server -ForegroundColor Green
        Copy-Item "app_offline.htm" "\$Server$Webroot"
        }
    }
}

Return SharePoint into Service

#Load SharePoint assembly
$Assemblies = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

#Check if the script is running on MOSS 2007
If (Test-Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12"){$Mode="2007"}

#Grab all Web Apps
$WebApps = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.WebApplications

#Retrieve Servers 
$Farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$SPServers = $Farm.Servers | Where {$_.Role -eq "Application"} | Foreach {$_.Name}

Foreach ($WebApp in $WebApps)
{
Foreach ($URL in $WebApp.AlternateUrls)
    {
    If ($Mode = "2007")
    {
    $WebRoot = ($WebApp.GetIisSettingsWithFallback($URL.URLZone)).Path.FullName -replace ":","$"
    }
    Else
    {
    $WebRoot = ($WebApp.GetIisSettingsWithFallback($URL.Zone)).Path.FullName -replace ":","$"
    }
    Write-Host "Removing the Holding Page for" $WebApp.Name "- Zone:" $Url.URLZone -ForegroundColor Green
    Foreach ($Server in $SPServers)
        {
        Write-Host "-Updating" $Server -ForegroundColor Green
        Remove-Item "\$Server$Webrootapp_offline.htm"
        }
    }
}


Leave a Reply

I've been low-key stressed about how to view the many email inboxes I have in Outlook in one view without having to scroll and hunt for new messages.

The 'macro' method in this video works great.

View Multiple Inboxes at Once in Outlook 365 https://youtu.be/NpFSsovHgVo via @YouTube

We help Department of Defense clients realize benefits such as faster decision making, total traceability, and automated updates by identifying targeted goals and putting an emphasis on a culture of adoption through buy-in by individual team members.

https://bit.ly/3IRc68a

How to: Create a report quickly from a #SharePoint list or library in the #PowerBI service
📈📉📊📈📉📊
https://bit.ly/3vbKfMD
#Microsoft365

Leverage Microsoft Project for the web with the Project Accelerator https://youtu.be/Hxr8dncHmT8 via @YouTube

Load More...