How to handle taking application offline

I have a web project with multiple sites and steps that need to be run for a deployment (deploy Website1, deploy website 2, update database, etc)

I want to put the website offline so that no one can access it while I am updating the database/websites.

Does anyone know a nice way (power shell script to take site off line via app_offline file?) to make my site offline until the whole deployment is complete?

Thanks,

Easy way is to slap a app_offline.htm file in the root directory of each site.

The hard part is knowing when all the requests have finished.

Turns out it was pretty easy …

@@@

Installation

#---------------
Import-Module WebAdministration
# see http://technet.microsoft.com/en-us/library/ee790588.aspx

cd IIS:\

if ( (Get-WebAppPoolState -Name $appPoolName).Value -eq “Stopped” )
{
Write-Host "AppPool already stopped: " + $appPoolName
}

Write-Host "Shutting down the AppPool: " + $appPoolName
Write-Host (Get-WebAppPoolState $appPoolName).Value

Signal to stop.

Stop-WebAppPool -Name $appPoolName

do
{
Write-Host (Get-WebAppPoolState $appPoolName).Value
Start-Sleep -Seconds 1
}
until ( (Get-WebAppPoolState -Name $appPoolName).Value -eq “Stopped” )
@@@

In case the next person who wants to do this searches first on tack overflow …