Forum Discussion
Fromelard
Apr 26, 2019Steel Contributor
PowerShell script to export Office 365 Groups Usage in CSV format used to Audit an Office 365 Tenant
After the previous scripts published to audit an Office 365 Tenant:
- https://techcommunity.microsoft.com/t5/SharePoint/PowerShell-script-to-export-SharePoint-Usage-in-CS...
- https://techcommunity.microsoft.com/t5/Microsoft-Stream-Forum/PowerShell-script-to-audit-and-export-...
- https://techcommunity.microsoft.com/t5/Office-365-Video/PowerShell-script-to-audit-and-export-all-co...
- https://techcommunity.microsoft.com/t5/Exchange/PowerShell-script-to-export-Exchange-Usage-in-CSV-fo...
- https://techcommunity.microsoft.com/t5/OneDrive-for-Business/PowerShell-script-to-export-OneDrive-Us...
- https://techcommunity.microsoft.com/t5/Microsoft-Teams/PowerShell-script-to-export-Microsoft-Teams-Usage-in-CSV-format/m-p/484713#M30563
This script is now dedicated to Office 365 Groups case.
[string]$ReportPath = ".\Reports\" [string]$username = "Admin@yourtenant.onmicrosoft.com" [string]$PwdTXTPath = "C:\SECUREDPWD\ExportedPWD-$($username).txt" $secureStringPwd = ConvertTo-SecureString -string (Get-Content $PwdTXTPath) $adminCreds = New-Object System.Management.Automation.PSCredential $username, $secureStringPwd $UserCredential = $adminCreds #$userCredential = Get-Credential $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $session $AllExistingGroups = Get-UnifiedGroup -IncludeAllProperties | Select ExternalDirectoryObjectId,Id,ServerName,Name,DisplayName,Alias,EmailAddresses,PrimarySmtpAddress,SharePointSiteUrl,Notes,Language, ManagedBy,ManagedByDetails,AccessType,GroupType,AutoSubscribeNewMembers,GroupMemberCount,GroupExternalMemberCount,WhenCreatedUTC,WhenChangedUTC $datestring = (get-date).ToString("yyyyMMdd-hhmm") $fileName = Join-Path -Path $ReportPath -ChildPath $("O365-Groups_"+ $datestring + ".csv") Write-host " -----------------------------------------" -ForegroundColor Green Write-Host (" >>> writing to file {0}" -f $fileName) -ForegroundColor Green $AllExistingGroups | Export-csv $fileName -NoTypeInformation Write-host " -----------------------------------------" -ForegroundColor Green
You can adapt that script as you need, based on your own requirements
Fabrice Romelard
French version:
Source used:
- http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2015/05/12/working-with-office-365-groups-using-powershell.aspx
- https://docs.microsoft.com/en-us/powershell/module/exchange/users-and-groups/get-unifiedgroup?view=exchange-ps
No RepliesBe the first to reply