Advertisement
private775

PS: SP - backup all site collections

Jan 26th, 2016
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $datS =  get-date -Format "yyyyMMdd"
  2. $datF =  get-date -Format "yyyyMMddHHmm"
  3.  
  4. $backupDir = "C:\temp\$($datS)"
  5.  
  6. if(-not $(Test-Path $backupDir)) {
  7.     mkdir $backupDir
  8. }
  9.  
  10. $waUrl = "http://contoso"
  11.  
  12. $sites = Get-SPSite -Limit ALL -WebApplication $waUrl
  13.  
  14. foreach($site in $sites){
  15.     $urlStr = $site.RootWeb.ServerRelativeUrl.Replace("/", "_")
  16.     $fname = "$($backupDir)\$($datF)$($urlStr).bak"
  17.  
  18.     backup-spsite -Identity $site.Url -Path $fname -Verbose -NoSiteLock -Confirm:$false
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement