Forum Discussion
Export all owners email adress for all Office 365 groups
- Jan 23, 2023My logic for only outputting one contact email address for an owner is that this is what I was asked to do by someone who explicitly requested the addition of this data...
Anyway, replace:
$GroupOwnerEmail = $GroupData[0].Mail }
with
$GroupUserMail = $GroupData.Mail -Join ", "
and you'll get the email addresses of all the owners.
BTW, the script is now at version 5.10, updated today to fix some annoying bugs introduced by Microsoft in the Get-ExoMailboxFolderStatistics cmdlet
Yep, $GroupOwnerMail is what you need.
To get the entries on separate lines is more problematic. Here's what I did:
First, create an array of the owner names instead of a string (no join)
[array]$GroupOwnerEmail = $GroupData.Mail
Then, for the output to the list used to drive the CSV and HTML output, add these lines before the line is generated ( $ReportLine = [PSCustomObject][Ordered]@{ )
$OFS="`n`n"
$ContactEmails = $Null
If ($G.GroupContact -ne $Null) { [string]$ContactEmails = $($G.GroupContact) }
Finally, make sure that the formatted string with line breaks is output in the report
ContactEmail = $ContactEmails
This technique uses the fact that you can define the PowerShell out field separator https://devblogs.microsoft.com/powershell/psmdtagfaq-what-is-ofs/ to include a new line escape sequence. It worked for me but might not be what you need for Power BI. Try it.
Regards,
Henrik