Running a report to view all DL's that AcceptMessagesOnlyFromSenders

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of Josh Farias Josh Farias 1 year, 2 months ago.

  • Author
  • #28854
    Profile photo of Josh Farias
    Josh Farias

    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
    instead of like the below
    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

  • #28855
    Profile photo of Don Jones
    Don Jones

    You're getting the semicolon-separated list because of the Join() you're doing. Also, I'm unclear why the ForEach is in there. It's essentially just keeping the Name property, despite the work you just did with the other property.

    Couldn't you just select the two properties you want, and then pipe that to Export-CSV?

    What's the end goal here?

  • #28860
    Profile photo of Josh Farias
    Josh Farias

    Thank you for getting back to me.
    The end goal here is to retrieve a list of users that are allowed to send messages to the DL's

    I found the above command online and it works but looking for a cleaner output.
    Im just learning Powershell so i have been trying different things.

    I basically just want the AcceptMessagesFromSendersorMembers and the DL Name

    so how would i go about that.

    select-Object -property Name,AcceptMessagesOnlyFromSendersorMembers

  • #28861
    Profile photo of Don Jones
    Don Jones

    The command might work, but it's a hot mess ;).

    Get-DynamicDistributionGroup | 
    where {$_.AcceptMessagesOnlyFromSendersOrMembers -ne $null} | 
    select-Object -property Name,AcceptMessagesOnlyFromSendersorMembers |
    Export-CSV filename.csv

    Try that. If it's not producing what you need, definitely hop back here and explain what you'd like to change, and I'll try and help. And more importantly, make sure you understand WHY this command is doing what it does. If you don't, ask – happy to explain whatever pieces you need. That's a lot more important than it just working.

  • #28866
    Profile photo of Josh Farias
    Josh Farias

    Thank you, this pulled the same info had in the previous command.

    my main thing im trying to do is pull an easy to read report for an exec that doesnt like the list of users being in one strand.

    So im trying to get a output to show each User on a separate line ill try to explain in the example below.

    DL NAme Name

    DL-all Users User 1
    User 2

    DL-Main Office User6
    User 7

    If it out outs the DL Name every time that is ok as well.
    Ive sent them the output i had before with users (LastName, FirstName) but only separated by a ; and they didn't like that.

    I hope this clears it up a little bit.
    Basically the end goal is to get an easy to read list of all the DL's and who is allowed to send to them.

    I appreciate any and all help.

You must be logged in to reply to this topic.