-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-SPOPermissions.ps1
32 lines (25 loc) · 969 Bytes
/
get-SPOPermissions.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#Admin Center & Site collection URL
$AdminCenterURL = Read-Host "Please enter the Admin URL of your sharepoint instance"
$CSVPath = "C:\Temp\GroupsReport.csv"
#Connect to SharePoint Online
Connect-SPOService -url $AdminCenterURL
$GroupsData = @()
#Get all Site collections
Get-SPOSite -Limit ALL | ForEach-Object {
Write-Host -f Yellow "Processing Site Collection:"$_.URL
#get sharepoint online groups powershell
$SiteGroups = Get-SPOSiteGroup -Site $_.URL
Write-host "Total Number of Groups Found:"$SiteGroups.Count
ForEach($Group in $SiteGroups)
{
$GroupsData += New-Object PSObject -Property @{
'Site URL' = $_.URL
'Group Name' = $Group.Title
'Permissions' = $Group.Roles -join ","
'Users' = $Group.Users -join ","
}
}
}
#Export the data to CSV
$GroupsData | Export-Csv $CSVPath -NoTypeInformation
Write-host -f Green "Groups Report Generated Successfully!"