Backing up IIS

*N.B. this is an old article and may no longer be relevant*

I came across this within a script tucked away on the Exchange Team blog downloads. I think it’s worth extracting and putting into its own script in case changes need to be made to IIS, as a rollback option. The following article goes into more detail about IIS behaviour and restoring from a backup:
http://blogs.iis.net/bills/archive/2008/03/24/how-to-backup-restore-iis7-configuration.aspx

Here’s the script. Save it as BackupIIS.ps1; it takes a minimicronanosecond to run.

function BackupIISConfig
{
Write-Host "Backing up current IIS configuration" -ForegroundColor green
pushd
Set-Location "$env:windir\System32\inetsrv"
$backup = "Exchange IIS Backup "+(get-date -format "MMddyyyy-hhmmss")
.\appcmd.exe ADD Backup $backup
Write-Host "Backup saved to: $env:windir\System32\inetsrv\backup\" -ForegroundColor Green
popd
}
BackupIISConfig


As I said, it's not my script and I'm not taking credit for it. But it's a good script and it's tucked away and I just thought that it would be useful to have it 'not' tucked away.