Created
August 21, 2019 11:33
-
-
Save OlafD/25d24ee63f56efef5d15e25fa1d7c382 to your computer and use it in GitHub Desktop.
When connected to a SharePoint site with PowerShell PnP, list all groups and the group members. The script will not show any kind of permissions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host | |
Write-Host "Groups Overview" | |
Write-Host "===============" | |
Write-Host | |
$groups = Get-PnPGroup | |
foreach ($group in $groups) | |
{ | |
Write-Host $group.Title | |
} | |
Write-Host " " | |
Write-Host "-----------------------------------------------------------" | |
Write-Host " " | |
Foreach ($group in $groups) | |
{ | |
$groupTitle = $group.Title | |
Write-Host "Group: $groupTitle" | |
Write-Host $("=" * ("Group: $groupTitle").Length) | |
Write-Host " " | |
$users = $group.Users | |
foreach ($user in $users) | |
{ | |
$userTitle = $user.Title | |
$userEmail = $user.Email | |
Write-Host "$userTitle ==> $userEmail" | |
} | |
Write-Host " " | |
Write-Host "-----------------------------------------------------------" | |
Write-Host " " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment