Tuesday, September 22, 2015

SharePoint 2013: Get title, url and site owners of all site collections via PowerShell

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$path = 'D:\Power-Shell-Scripte\SolutionFarmSiteCollections.csv';
$sitesList = @()
foreach($webApp in Get-SPWebApplication) {
    # get all site collections of web applications except this one
    if($webApp.Url -ne "http://my-sp01Nintex:4711/"){   
        foreach($site in $webApp.Sites){
            $ps_obj = New-Object PSObject -Property @{
                "WebApplication" = $webApp.Url
                 "Site Title" = $site.RootWeb.Title
                 "Site Url" = $site.Url
                 "Primary Owner" = $site.Owner
                 "Secondary Owner" = $site.SecondaryContact
            }
           $sitesList += $ps_obj  
        }
    }
}

# Export to csv file 
$sitesList | Export-Csv -path $path -Delimiter ";"

No comments:

Post a Comment