question

AustinSundar-2506 avatar image
0 Votes"
AustinSundar-2506 asked KaelYao-MSFT commented

Export DL owners in smtp formt

i am trying to export DL owners in smtp format. but the formatting seems to incorrect

These are the challenges facing
- some of the DLs have multiple owners
- export managed by field in smtp format

the code that i am using is

 Get-DistributionGroup -ResultSize unlimited|?{$_.DisplayName -like "*user*"}| Select DisplayName, PrimarySmtpAddress,@{Name='EmailAddresses'; Expression={$_.EmailAddresses -join ","}}, OrganizationalUnit, @{n="ManagedBy";e={(Get-Recipient $($_.ManagedBy)).PrimarySmtpAddress -join ","}}, LegacyExchangeDN, DistinguishedName|Export-Csv "DLs _$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).csv" -NoTypeInformation




office-exchange-server-administration
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

michev avatar image
1 Vote"
michev answered

I'd suggest you use a proper script instead of oneliner, than handle those challenges accordingly. Looping over each owner should give you the possibility to fetch the corresponding SMTP address, which you can then stitch together.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KaelYao-MSFT avatar image
0 Votes"
KaelYao-MSFT answered KaelYao-MSFT commented

Hi @AustinSundar-2506

If there are multiple owners, you may modify the @{n="ManagedBy";e={(Get-Recipient $($_.ManagedBy)).PrimarySmtpAddress -join ","}}, part to export all owners.

 Get-DistributionGroup -ResultSize unlimited | ?{$_.DisplayName -like "*user*"} | Select DisplayName, PrimarySmtpAddress,@{Name='EmailAddresses'; Expression={$_.EmailAddresses -join ","}}, OrganizationalUnit, @{n="ManagedBy";e={$_.ManagedBy | Foreach {(Get-Recipient $_).PrimarySMTPAddress}}}, LegacyExchangeDN, DistinguishedName | Export-Csv "DLs _$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).csv" -NoTypeInformation

Result:
152066-57.png


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


57.png (21.2 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @AustinSundar-2506

Just checking in to see if above information was helpful. Please let us know if you would like further assistance.

0 Votes 0 ·