0

I am trying to get the following information from all my sites.

Site Name, Site URL, Users with Full Control(in groups or not), User Email

I am able to get the Site Name and Site URL with Powershell. Anybody know how to also get users with full control and their email? (I tried but couldn't get users that were in groups along with those who weren't and it was a separate script, want them combined in one excel doc.). Thanks.

1 Answer 1

0

You could try this powershell script Site Name, Site URL, Users with Full Control(in groups or not), User Email

  $Url="http://sp"
  $web= Get-SPWeb $Url

    Write-Host $web.Title $web.Url-ForegroundColor red
    $roles=$web.get_Roles()
    Foreach($role in $roles)
    {
    if( $role.Name  -eq "Full Control"){
        Write-Host "permission level" $role.Name -ForegroundColor green
        Write-Host "group has this permission:"
        $groups=$role.Groups
        if($groups.Count -eq 0){
            Write-Host "no group has this permissoon" -ForegroundColor red
        }else{
            Foreach($group in $groups)
            {
             Write-Host $group
             $groupUsers=$group.Users
             if($groupUsers.Count -eq 0){
                Write-Host "this group does not has users"
             }else{
                Foreach($groupUser in $groupUsers){
                
                Write-Host "User:" $groupUser "Email:"$groupUser.Email
                }
             }
            }
        
        }    
        Write-Host "-------------"
        Write-Host "user has this permission:"
        
        $users = $role.Users 
        if($users.Count -eq 0){
            Write-Host "no user has this permissoon directly" -ForegroundColor red
        }else{
            Foreach($user in $users)
            {
             Write-Host "User:" $user "Email:"$user.Email
            }
        }
        }
    }

Test result: enter image description here

2
  • Hi Amos, Thanks for your reply. I need all of this in a spreadsheet. Is there anyway to get Site, SiteURL, User, UserEmail, Role Name all in one line? Commented Nov 11, 2020 at 13:29
  • stackoverflow.com/questions/21047185/… You could refer to this issue to export data to csv, Some data has many values, I think the experience will not be very good. Commented Nov 12, 2020 at 9:21

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.