1

I am able to return for "sitecollectionURL" the primary and secondary admins using the followins PS:

Get-SPSite "sitecollectionURL" | foreach-object{ Write-host $_.Url - $_.RootWeb.Title - $_.Owner.Name - $_.SecondaryContact.Name}

but what I really want is all the ones listed on site settings > site collection owners group (different than primary and secondary site collection admin) and also the site settings > site collection administrators.

2 Answers 2

3

No need to have a query for finding the owners group.

If you do not know the name of "owners group", the web by default gives you the property $web.associatedownersgroup .

This returns the owners group .

2

Are you referring to the Site Collection Owners group?

In that case, use the following:

$web = get-spweb "RootWeb Url"
$web.Groups | Where {$_.Name -eq "Site Collection Owners"} | select Users 

To get the Site Collection Administrators, use the following ($web has the same value as above):

$web.SiteAdministrators

Edit: If you do not know the name of the Owners group, you can still retrieve the groups that have Full Control access on the site, which usually includes the "Owners" (here $web has the same value as above):

$web.Groups | ?{$_.Roles.Name -contains "Full Control"}  | select Name,Roles
4
  • Thank you Chris Odegard, it works if I know the Site Collection Owners group name, but if I don't know it then how can I get it? Should the approach then will be to get all people who have full control permissions to the site collection? How to do that with PS?
    – MLC
    Oct 26, 2018 at 17:07
  • For SiteAdministrators the sentence returned with no results
    – MLC
    Oct 26, 2018 at 17:22
  • @MLC That may work, assuming there are not a lot of groups with Full Control on the Site: $web.Groups | ?{$_.Roles.Name -contains "Full Control"} | select Name,Roles Oct 26, 2018 at 21:35
  • @MLC re: Site Administrators, are you sure that the group is populated? Check here: https://<Root Web URL>/_layouts/15/mngsiteadmin.aspx Also, where are you running PowerShell? Oct 26, 2018 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.