Wednesday, July 30, 2014

SharePoint 2010: Get All Site Collections

How to get all Site Collections from one Web Application?

So here is the script:

clear
$rSite = Get-SPSite "SOMESITECOLLECTION"
$spWebApp = $rSite.WebApplication
$stream = [System.IO.StreamWriter] "FILELOCATION.csv"
foreach($site in $spWebApp.Sites)
{
$web = $site.RootWeb
$stream.WriteLine($web.Url + "," + $web.Title)
$site.Dispose()
}
$stream.close()
$rootSite.Dispose()

No comments:

Post a Comment