[O365] Find All Office 365 Group Owners using PowerShell
#Connect to Exchange Online
Connect-ExchangeOnline -ShowBanner:$False
#Get All Office 365 Groups
$GroupData = @()
$Groups = Get-UnifiedGroup -ResultSize Unlimited -SortBy Name
#Loop through each Group
$Groups | Foreach-Object {
#Get Group Owners
$GroupOwners = Get-UnifiedGroupLinks -LinkType Owners -Identity $_.Id | Select DisplayName, PrimarySmtpAddress
$GroupData += New-Object -TypeName PSObject -Property @{
GroupName = $_.Alias
GroupEmail = $_.PrimarySmtpAddress
OwnerName = $GroupOwners.DisplayName -join "; "
OwnerIDs = $GroupOwners.PrimarySmtpAddress -join "; "
SharePointSiteUrl = $_.SharePointSiteUrl -join "; "
DisplayName = $_.DisplayName -join "; "
}
}
#Get Groups Data
#$GroupData
$GroupData | Export-Csv "C:\Temp\GroupOwners.csv" -NoTypeInformation
#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False
Connect-ExchangeOnline -ShowBanner:$False
#Get All Office 365 Groups
$GroupData = @()
$Groups = Get-UnifiedGroup -ResultSize Unlimited -SortBy Name
#Loop through each Group
$Groups | Foreach-Object {
#Get Group Owners
$GroupOwners = Get-UnifiedGroupLinks -LinkType Owners -Identity $_.Id | Select DisplayName, PrimarySmtpAddress
$GroupData += New-Object -TypeName PSObject -Property @{
GroupName = $_.Alias
GroupEmail = $_.PrimarySmtpAddress
OwnerName = $GroupOwners.DisplayName -join "; "
OwnerIDs = $GroupOwners.PrimarySmtpAddress -join "; "
SharePointSiteUrl = $_.SharePointSiteUrl -join "; "
DisplayName = $_.DisplayName -join "; "
}
}
#Get Groups Data
#$GroupData
$GroupData | Export-Csv "C:\Temp\GroupOwners.csv" -NoTypeInformation
#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False
Comentarios