kwizcom banner advertisement

SharePoint Online: PowerShell to Get All Groups

Requirement: SharePoint Online PowerShell to List All Groups in a Site Collection

Get SharePoint Online Groups using PowerShell: Get-SPOSiteGroup
The Get-SPOSiteGroup PowerShell cmdlet displays a list of all existing SharePoint groups for a specific site collection. Use SharePoint Online Management Shell console to get user groups in SharePoint Online.

Get-SPOSiteGroup -Site <Site-Collection-URL>

This PowerShell cmdlet gets you all SharePoint groups, its permission levels and users in a site collection. You can get the permission level(s) associated with each group in the site collection by accessing the Roles property of a group.

SharePoint Online PowerShell to List All Groups
Here is an example:
#Admin Center URL
$AdminCenterURL = "https://crescenttech-admin.sharepoint.com/"
 
#Connect to SharePoint Online
Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)

#Get All Groups of a site collection
Get-SPOSiteGroup -Site "https://crescenttech.sharepoint.com/sites/marketing"

Lets get all Groups, Group permissions and group users
#Get Group Name, Role and Users
Get-SPOSiteGroup -site https://crescenttech.sharepoint.com/sites/marketing | Select Title, Roles, Users
sharepoint online powershell list all groups

SharePoint Online: PowerShell to Get Group 
Use Get-SPOSiteGroup cmdlet with Group parameter to get a group in SharePoint Online site.
Get-SPOSiteGroup -Site "https://crescenttech.sharepoint.com/sites/marketing" -Group "Marketing Owners"

Export SharePoint Online Groups Data to CSV:
#Admin Center & Site collection URL
$AdminCenterURL = "https://crescenttech-admin.sharepoint.com/"
$SiteURL = "https://crescenttech.sharepoint.com/sites/marketing"
$CSVPath = "C:\Temp\Groups.csv"

#Connect to SharePoint Online
Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)

#Get All Groups of a site collection
$Groups = Get-SPOSiteGroup -Site $SiteURL
Write-host "Total Number of Groups Found:"$Groups.Count

$GroupsData = @()
ForEach($Group in $Groups)
{
    $GroupsData += New-Object PSObject -Property @{
        'Group Name' = $Group.Title
        'Permissions' = $Group.Roles -join ","
        'Users' =  $Group.Users -join ","
    }
}
#Export the data to CSV
$GroupsData | Export-Csv $CSVPath -NoTypeInformation 
Here is my another post to get SharePoint Online groups from all site collections: SharePoint Online: Site Users and Groups Report using PowerShell
SharePoint Online: PowerShell to Get All Groups SharePoint Online: PowerShell to Get All Groups Reviewed by Salaudeen Rajack on March 13, 2018 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.