In this blog, we are going to see how to get the list of available groups and users from SharePoint site using PnP PowerShell.
The below PowerShell command retrieves all the SharePoint Groups from the SharePoint site and its users with users count for the group.
Get-PnPGroup PnP PowerShell cmdlet gets the SharePoint Groups from the SharePoint site collection.
- PS:> $cred = Get-Credential
- PS:> Connect-PnPOnline -Url https://<tenant>.sharepoint.com/sites/dev -Credential $cred
- PS:> $groups = Get-PnPGroup | Select-Object Title,Users
- PS:> $groups | format-table @{Expression = {$_.Title};Label='Group'},@{Expression = {$_.Users.Title};Label='Users'},@{Expression = {$_.Users.Count};Label='UsersCount'}


Raymond FischerPosted Sep 7, 2020, 9:19 AM
Thanks Shantha for the great article. I will save and use and reuse. Very good, sir!
Darrell JohnsonPosted Dec 1, 2017, 4:48 PM
Since my groups have a lot of users I received overflow ellipses ... in the output. I removed the buffer via: $FormatEnumerationLimit = -1 I also changed the output formatting to a file via: $groups | Format-Table -Wrap -AutoSize @{Expression = {$_.Title};Label='Group'},@{Expression = {$_.Users.Title};Label='Users'},@{Expression = {$_.Users.Count};Label='UsersCount'} | Out-String -Width 4096 | Out-File C:\file.txt
Darrell JohnsonPosted Dec 1, 2017, 2:15 PM
Thanks SO MUCH! This PnP is a blessing for permissions discovery.