3

Can you please give me a script or commands to get the all the list of users are having site owner and full control access from sites/sub-sites in a site collection.

I tried this but it is not giving all site owners and full control users.

Get-SPWebApplication http://sharepoint.com | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, ID, Author | Export-CSV D:\siteowners.csv -NoTypeInformation
  • This PowerShell query is working fine. For the Full Control users you would need to query the permission groups. – Paul Strupeikis Mar 11 '16 at 11:04
1

Try the following:

$webapp = Get-SPWebApplication https://SharePoint.domain.com
$sites = $webapp | Get-SPSite -Limit All
$webs =  $sites | Get-SPWeb -Limit All
foreach ($web in $webs) {
    $users = $web.siteusers
    write-host "Processing " $web.url -foregroundcolor cyan
    write-host "Site Admins:" -foregroundcolor yellow
    foreach ($user in $users) {
        if ($user.IsSiteAdmin) {
            write-host $user.Name
        }
        #write-host $user.Name "IstSiteAdmin: " $user.isSiteAdmin
    }
    Write-host "Site Owners" -foregroundcolor green
    foreach ($user in $users) {
        if ($web.DoesUserHavePermissions($user,[Microsoft.SharePoint.SPBasePermissions]::FullMask)) {
            write-host $user.Name
        }
    }
}

This Gives a list of site admins for the site to start with, then a list of users with the Full Control permission to the site.

0
$users = $web.AllUsers 

in stead of

$users = $web.siteusers

It's faster

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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