Last active
June 26, 2024 20:58
-
-
Save joerodgers/fa4f34e9fde1042658f09ad800d4ebdb to your computer and use it in GitHub Desktop.
This file contains 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
#requires -modules "PnP.PowerShell" | |
Connect-PnPOnline ` | |
-Url "https://$env:O365_TENANT-admin.sharepoint.com" ` | |
-ClientId $env:O365_CLIENTID ` | |
-Thumbprint $env:O365_THUMBPRINT ` | |
-Tenant $env:O365_TENANTID ` | |
-ErrorAction Stop | |
$unifiedGroups = Get-PnPMicrosoft365Group | |
$publicUnifiedGroups = $unifiedGroups | Where-Object -Property Visibility -eq "public" | |
$results = foreach( $unifiedGroup in $publicUnifiedGroups ) | |
{ | |
# this method avoids a access token expiration issue | |
$unifiedGroupDetail = Get-PnPMicrosoft365Group -Identity $unifiedGroup.GroupId -IncludeSiteUrl -IncludeOwners | |
[PSCustomObject] @{ | |
GroupName = $unifiedGroup.DisplayName | |
GroupId = $unifiedGroup.Id | |
CreatedDateTime = $unifiedGroup.CreatedDateTime | |
GroupOwnerEmails = $unifiedGroupDetail.Owners.Email -join ";" | |
SiteUrl = $unifiedGroupDetail.SiteUrl | |
IsMicrosoftTeamsConnected = $unifiedGroup.HasTeam | |
IsVivaEngageConnected = $unifiedGroup.CreationOptions -contains "YammerProvisioning" | |
} | |
} | |
$timestamp = Get-Date -Format FileDateTime | |
$results | Export-Csv -Path "PublicM365Groups_$timestamp.csv" -NoTypeInformation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment