List of all sites in a Farm in Sharepoint 2013 onpremises with their members group owner

susmitha 266 Reputation points
2022-04-12T11:10:24.377+00:00

Hello,

I have gotten list of all sites in a farm along with owners in the respective site. But currently our requirement is to get list of all sites in a Farm along with their site members group's Group owner details but not list of members in owner's group.

In our current environment, we add site owner(lets say me) as "Group owner" for the respective sitemembers group. So, we need list of all the sites in the Farm along with Group owner details of members group.

Could someone kindly help me on this?

Regards,
Susmitha.

SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,972 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 37,151 Reputation points Microsoft Vendor
    2022-04-14T09:41:54.053+00:00

    Hi @susmitha ,
    You can refer to following code to retrieve details

    #Set the Web application URL  
    $WebAppURL="https://xxx.sharepoint.com"  
       
    #Get the Web Application         
    $WebApp = Get-SPWebApplication $WebAppURL  
       
    #Get all Site collections from the web application  
    $SitesCollection  = $WebApp.Sites  
       
    #Enumerate all site collections in the web application  
    Foreach($Sites in $SitesCollection)  
    {  
        #Get Site Collection URL, Owner, Content Database Details   
        $SiteURL = $Sites.URL  
        Write-host $Sites.URL  
        $site = new-object Microsoft.SharePoint.SPSite($siteCollURL)  
        $web = $site.openweb()  
        $siteUsers = $web.SiteUsers  
        Write-Host "Site Collection URL:" , $siteCollURL  
       foreach($user in $siteUsers)  
        {  
          if($user.IsSiteAdmin -eq $true)  
          {  
            Write-Host "User Name: ", $user.LoginName , "Role: Admin"  
        }  
       else  
       {  
         Write-Host "User Name: ", $user.LoginName, "Role: User"  
       }  
     }  
    $web.Dispose()  
    $site.Dispose()  
      
    }  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.