locked
Cmdlet to get AcceptMessagesOnlyFrom property for Distribution groups RRS feed

  • Question

  • Hello

    My requirement -> Want a cmdlet to get acceptmessagesonlyfrom property for all DL's in the organisation and export that into .csv

    I ran Get-DistributionGroup -ResultSize Unlimited|fl AcceptMessagesOnlyFrom|out-file 'c:\acceptmessages.csv' ,is only giving me AcceptMessagesOnlyFrom value , how do i insert each DL names inot the CSV as well ?I tried add-content but not working .........

    Help required

     

    Tuesday, September 8, 2009 4:30 AM

Answers

  • Try this version, it is probably due to multiple addresses in AcceptMessagesOnlyFrom. You should see a list of addresses delimited by semicolon in the AcceptMessagesOnlyFrom csv column:


    Get-DistributionGroup -ResultSize Unlimited -filter {AcceptMessagesOnlyFrom -ne $null} | select-object Name,@{Name="AcceptMessagesOnlyFrom";Expression={[string]::join(";",$_.AcceptMessagesOnlyFrom)}} | export-csv c:\acceptmessages.csv

    Shay Levy [MVP]
    http://blogs.microsoft.co.il/blogs/ScriptFanatic
    PowerShell Toolbar
    • Marked as answer by Shay Levi Wednesday, September 9, 2009 8:33 AM
    Wednesday, September 9, 2009 6:30 AM
  • Glad it worked...

    Thanks a lot Levi
    • Marked as answer by Faizan Syed Wednesday, September 9, 2009 7:24 AM
    Wednesday, September 9, 2009 7:23 AM

All replies

  • This will export the Name and AcceptMessagesOnlyFrom properties for groups that has a value in AcceptMessagesOnlyFrom:

    Get-DistributionGroup -ResultSize Unlimited -filter {AcceptMessagesOnlyFrom -ne $null} | select-object Name,AcceptMessagesOnlyFrom | export-csv c:\acceptmessages.csv
    Shay Levy [MVP]
    http://blogs.microsoft.co.il/blogs/ScriptFanatic
    PowerShell Toolbar
    • Proposed as answer by BSonPosh Tuesday, September 8, 2009 7:17 PM
    Tuesday, September 8, 2009 1:49 PM
  • I got the name of the groups but in place of AcceptMessagesOnlyFrom filed i'm getting "Microsoft.Exchange.Data.MultiValuedProperty`1[Microsoft.Exchange.Data.Directory.ADObjectId]" without quotes

    Any ideas? it is happening for every group. Is it because there are maultiple entries in the object? My earlier cmdlet was not popping such error
     
    Wednesday, September 9, 2009 4:46 AM
  • Try this version, it is probably due to multiple addresses in AcceptMessagesOnlyFrom. You should see a list of addresses delimited by semicolon in the AcceptMessagesOnlyFrom csv column:


    Get-DistributionGroup -ResultSize Unlimited -filter {AcceptMessagesOnlyFrom -ne $null} | select-object Name,@{Name="AcceptMessagesOnlyFrom";Expression={[string]::join(";",$_.AcceptMessagesOnlyFrom)}} | export-csv c:\acceptmessages.csv

    Shay Levy [MVP]
    http://blogs.microsoft.co.il/blogs/ScriptFanatic
    PowerShell Toolbar
    • Marked as answer by Shay Levi Wednesday, September 9, 2009 8:33 AM
    Wednesday, September 9, 2009 6:30 AM
  • Glad it worked...

    Thanks a lot Levi
    • Marked as answer by Faizan Syed Wednesday, September 9, 2009 7:24 AM
    Wednesday, September 9, 2009 7:23 AM
  • Hi Shay,

    Your script works and pulls the complete list of the AcceptMessagesOnlyFrom field. I do have a further requirement that I can't seem to figure out on my own.

    The output of your code: @{Name="AcceptMessagesOnlyFrom";Expression={[string]::join(";",$_.AcceptMessagesOnlyFrom)}} pulls the full LDAP path to the user object. Is there any way to just get the users name only?

    Yours: domain.com/OUName/OUname/Ouname/Users full name;domain.com/OUName/OUname/Ouname/Users full name;domain.com/OUName/OUname/Ouname/Users full name;domain.com/OUName/OUname/Ouname/Users full name;....

    What I'm looking for is:

    Users full name;Users full name;...

    Is there anyway to get this information formatted to the above example?

    Here is my code:

    Get-DistributionGroup $group.name.ToString() | Select-Object @{Name="GrantSendOnBehalfTo";Expression={[string]::join(";",$_.GrantSendOnBehalfTo)}}, @{Name="AcceptMessagesOnlyFromDLMembers";Expression={[string]::join(";",$_.AcceptMessagesOnlyFromDLMembers)}}, @{Name="AcceptMessagesOnlyFrom";Expression={[string]::join(";",$_.AcceptMessagesOnlyFrom)}} | fl | out-file -append $outfile

    Any help would be appreciated.

    Thanks,

    Chris

    Tuesday, January 25, 2011 5:40 PM
  • Sure

     

    Get-DistributionGroup -ResultSize Unlimited -filter {AcceptMessagesOnlyFrom -ne $null} | select
    -object Name,@{Name="AcceptMessagesOnlyFrom";Expression={[string]::join(";",($_.AcceptMessagesOnlyFrom| foreach {$_.name
    })
    )}}


    Shay Levy [MVP]
    PowerShay.com
    PowerShell Toolbar
    • Proposed as answer by Yeliab Tuesday, January 25, 2011 7:47 PM
    Tuesday, January 25, 2011 5:47 PM
  • Thanks Shay, it works like a charm.
    Tuesday, January 25, 2011 7:47 PM
  • Hey Guys,

    can any of ye tell me how to add multiple people to the AcceptMessagesOnlyFrom property, using powershell if possible????

     

    Wednesday, July 6, 2011 10:13 AM
  • Shay, I know this has been a while, but I don't know if it is a good idea to create a new thread, especially since this almost does what we want (and I thank you for it!).

    I've used your command:

    Get-DistributionGroup -ResultSize Unlimited -filter {AcceptMessagesOnlyFrom -ne $null} | select-object Name,@{Name="AcceptMessagesOnlyFrom";Expression={[string]::join(";",($_.AcceptMessagesOnlyFrom| foreach {$_.name}))}} | export-csv c:\DistList.csv

    and works great, but it does not list security groups or it's members who are also in the "AcceptMessagesOnlyFrom" attribute.  Is there a way to also list the security groups as well?

    Thanks.

    Tuesday, July 17, 2012 3:40 PM
  • Now don't make us say this...this thread is closed...please open a new one.

    ¯\_(ツ)_/¯

    Tuesday, July 17, 2012 9:13 PM
  • Guy Techie,

    Did you ever get an answer to your question concerning the Get-DistributionGroup command that captures security groups also?  I could use the help.  Thanks.

    • Proposed as answer by Xemanth Wednesday, December 27, 2017 9:04 AM
    • Unproposed as answer by Xemanth Wednesday, December 27, 2017 9:04 AM
    Tuesday, November 27, 2012 8:46 PM
  • Hi,

    This question is already marked as answered. If you still need help, please start a new question.

    Bill

    Tuesday, November 27, 2012 9:33 PM