Running a report to view all DL's that AcceptMessagesOnlyFromSenders

I have this command that works great it gets me what i need but i was wondering if it there is a way to break down the list of users.  For example instead of having the users listed in one continuous string to be broken down like below

USer1

USer2 

instead of like the below

User1;User2;User3

this is the script that im using

Get-DynamicDistributionGroup | where {$_.AcceptMessagesOnlyFromSendersOrMembers -ne $null} | Select Name,@{Name=AcceptMessagesOnlyFromSendersorMembers;Expression={[string]::join(;,($_.AcceptMessagesOnlyFromSendersorMembers | foreach {$_.Name}))}} | Export-Csv C:\MailDistrGroupAccept.csv -NoType -Force

any help would be great

August 19th, 2015 1:06pm

You could try using `n in the join.

I have not tried this, so no guarantees.

Free Windows Admin Tool Kit Click here and download it now
August 19th, 2015 1:08pm

You can split the string like this:

[string]$Users.Split(";")

That would return an array which would be shown as u want it. But i think that this can not be integrated in your command without side effects.

Also you can use the -join command from powershell:

Get-DynamicDistributionGroup | where {$_.AcceptMessagesOnlyFromSendersOrMembers -ne $null} | Select Name,@{Name=AcceptMessagesOnlyFromSendersorMembers;Expression={$_.AcceptMessagesOnlyFromSendersorMembers.Name -join "`n`r"))}} | Export-Csv C:\MailDistrGroupAccept.csv -NoType -Force
Hopefully this script works - i couldnt test it.

August 19th, 2015 3:11pm

Hi Josh,

Is there any update on this issue? Does the above suggestions work?

Looking forward to your feedback.

Best Regards,

Elaine

Free Windows Admin Tool Kit Click here and download it now
August 24th, 2015 9:47pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics