Created
March 26, 2013 11:52
-
-
Save ciphertxt/5244838 to your computer and use it in GitHub Desktop.
Backup the web.config for a given web application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$webappName = “http://intranet.contoso.com” | |
$backupDir = “C:\backups” | |
Write-Host "Backing up $webappName web.config file…" -foreground Gray –nonewline | |
## Get the web application – by display name | |
$w = Get-SPWebApplication | where { $_.DisplayName -eq "$webappName"} | |
## Get the default (first) zone for the web app… | |
## You may wish to iterate through all the available zones | |
$zone = $w.AlternateUrls[0].UrlZone | |
## Get the collection of IIS settings for the zone | |
$iisSettings = $w.IisSettings[$zone] | |
## Get the path from the settings | |
$path = $iisSettings.Path.ToString() + "\web.config" | |
## copy the web.config file from the path | |
copy-item $path -destination $backupDir\$webappName | |
Write-Host "done" -foreground Green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment