Script to Export Office 365 Group Information to CSV
Office 365 Groups Comprehensive Export Script
Section titled “Office 365 Groups Comprehensive Export Script”Overview
Section titled “Overview”This PowerShell script provides comprehensive extraction of Office 365 Groups information across your Microsoft 365 tenant. By capturing detailed group metadata including ownership, membership, privacy settings, SharePoint integration, and creation timestamps, this script enables thorough group auditing, governance analysis, and organizational collaboration review.
Key Features
Section titled “Key Features”| Feature | Capability | Business Value |
|---|---|---|
| Complete Group Inventory | Retrieves all Office 365 groups organization-wide | Provides comprehensive group landscape view |
| Ownership Tracking | Captures group owners and their contact information | Enables accountability and access management |
| Membership Analysis | Lists all group members with email addresses | Supports license planning and access review |
| Privacy Classification | Documents group privacy settings (Public/Private) | Assists with compliance and governance |
| SharePoint Integration | Captures associated SharePoint site URLs | Provides collaboration platform mapping |
| Metadata Timestamps | Records creation and modification dates | Enables lifecycle management tracking |
Script Configuration
Section titled “Script Configuration”Prerequisites
Section titled “Prerequisites”- Exchange Online PowerShell module installed
- Exchange Administrator or appropriate permissions
- Sufficient disk space for export files
- Network connectivity to Exchange Online
Required Variables
Section titled “Required Variables”$csvFilePath = "Office365GroupsInfo.csv" # Output file pathImplementation Script
Section titled “Implementation Script”# Specify CSV file path for export$csvFilePath = "Office365GroupsInfo.csv"
# Get all Office 365 groups in the tenant
$groups = Get-UnifiedGroup -ResultSize Unlimited
# Prepare CSV data
$csvData = foreach ($group in $groups) {
[PSCustomObject]@{ 'Group Name' = $group.DisplayName 'Group Alias' = $group.Alias 'Group Type' = $group.GroupType 'Owners' = (Get-UnifiedGroupLinks -Identity $group.DistinguishedName -LinkType Owners | Select-Object -ExpandProperty PrimarySmtpAddress | ForEach-Object {$_}) -join ',' 'Members' = (Get-UnifiedGroupLinks -Identity $group.DistinguishedName -LinkType Members | Select-Object -ExpandProperty PrimarySmtpAddress | ForEach-Object {$_}) -join ',' 'Privacy' = $group.AccessType 'Managed By' = $group.ManagedBy 'Description' = $group.Description 'Creation Time' = $group.WhenCreated 'Last Modified Time' = $group.WhenChanged 'Site URL' = $group.SharePointSiteUrl }}
# Export to CSV
$csvData | Export-Csv -Path $csvFilePath -NoTypeInformation -Force