Skip to content

Instantly share code, notes, and snippets.

@OlafD
Created August 21, 2019 11:33
Show Gist options
  • Save OlafD/25d24ee63f56efef5d15e25fa1d7c382 to your computer and use it in GitHub Desktop.
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.
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