— part of check-in
on branch trunk
— List all the members of the “AssociatedOwnerGroup” of each site (including root site) of each Site Collection of each Web Application in the farm.
# encoding: ascii
# api: powershell
# title: SharePoint Site Owners
# description: List all the members of the “AssociatedOwnerGroup” of each site (including root site) of each Site Collection of each Web Application in the farm.
# version: 0.1
# author: Lucas Araujo
# license: CC0
# x-poshcode-id: 4347
# x-derived-from-id: 4348
# x-archived: 2015-05-16T08:54:08
# x-published: 2015-07-31T21:09:00
# Writes down the result to CSV files
Get-SPWebApplication | Get-SPSite -Limit ALL |
$content = "";
$rootSite = New-Object Microsoft.SharePoint.SPSite($_.Url)
$subSites = $rootSite.AllWebs;
if($subSites.Count -le 0)
@@ This occurs when a Site Collection does not contains any subsite (not even the root site)
Write-Host "The Site Collection" $siteUrl "does not contains any site."
foreach($subsite in $subSites)
$siteOwners = $subsite.AssociatedOwnerGroup
foreach ($owner in $subsite.Users)
$content += "$($subsite.ParentWeb.Url),$($owner.Name),Site Owner`n"
$content += "$($subsite.Url),$($owner.Name),Site Owner`n"
$content += "Could not find an AssociatedGroupOwner in the site with the Url: $($subsite.Url) `n"
@@ Set the patch to the CSV files
$FilePath = "C:\Owners\" + $_.Url.Replace("http://","").Replace("/","-").Replace(":","-") + ".csv";
out-file -filepath $FilePath -inputobject $content