question

GlennMaxwell-2309 avatar image
0 Votes"
GlennMaxwell-2309 asked EricYin-MSFT commented

DLs export

Hi All

I have users list in a csv file in the below format. i want to pull all the DLs and unified groups these users are members of. How can i export this information to a csv file. experts guide me on this.

users
user1@contoso.com
user2@contoso.com

office-exchange-server-administrationoffice-exchange-online-itprooffice-online-server-generaloffice-online-server-exchange
· 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 @GlennMaxwell-2309,

Your issue is more related to Exchange, I will remove tag "office-sharepoint-online".

Thank you for your support and understanding.

0 Votes 0 ·
EricYin-MSFT avatar image
0 Votes"
EricYin-MSFT answered

Hi,
Assuming you have a csv/txt file like this:

 name
 user1
 user2
 administrator

Run the following script in EMS:

  $names= Import-Csv c:\temp\name.csv
  $Result= @() 
  $groups= Get-DistributionGroup
  foreach ($name in $names) {
  foreach($group in $groups){
  $members= Get-DistributionGroupmember $group
  foreach ($member in $members){
  if ($member.name -eq $name.name){
  $Result1 = New-Object PSObject 
  $Result1 | Add-Member NoteProperty -Name "User" -Value $name.name
  $Result1 | Add-Member NoteProperty -Name "group" -Value $group
  $Result += $Result1
  }}}}
  $Result|Export-csv -Path c:\temp\result.csv -NoTypeInformation



If an Answer is helpful, please click "Accept Answer" and upvote it.
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.


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.

AshokM-8240 avatar image
0 Votes"
AshokM-8240 answered

Hi @GlennMaxwell-2309 ,

Please refer the below link for the similar query,

https://docs.microsoft.com/en-us/answers/questions/105946/user-access-to-distribution-lists-and-unified-grou.html

If the above suggestion helps, please click on "Accept Answer" and upvote it.

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.

GlennMaxwell-2309 avatar image
0 Votes"
GlennMaxwell-2309 answered EricYin-MSFT edited

i am using exchange hybrid environment, i have few DLs in onprem and few DLs in cloud, when i use this syntax in cloud i am getting error.

WARNING: The object DL1 has been corrupted or isn't compatible with Microsoft support
requirements, and it's in an inconsistent state. The following validation errors happened:
WARNING: The group "DL1" is not managed by any recipient but the MemberJoinRestriction
property is set to "ApprovalRequired".


Cannot process argument transformation on parameter 'Identity'. Cannot convert the "DL2" value of type
"Deserialized.Microsoft.Exchange.Data.Directory.Management.DistributionGroup" to type
"Microsoft.Exchange.Configuration.Tasks.DistributionGroupMemberIdParameter".
+ CategoryInfo : InvalidData: (:) [Get-DistributionGroupMember], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-DistributionGroupMember
+ PSComputerName : outlook.office365.com

How can i export unified groups for the users

· 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.

Run "Get-Distributiongroup DL1|fl MemberJoinRestriction", is it set to ApprovalRequired? Arrange a manager for DL1 and see if the warning exists again.

The error might be due to there is a space in "DL2"'s name, or some character like underscore, right? Try if you can rename it with only words and run the script again.

0 Votes 0 ·
GlennMaxwell-2309 avatar image
0 Votes"
GlennMaxwell-2309 answered EricYin-MSFT commented

i am getting the below warning, i have also used the below syntax.


$Result | -Result size Unlimited Export-csv -Path c:\temp\result.csv -NoTypeInformation

WARNING: By default, only the first 1000 items are returned. Use the ResultSize parameter to specify the number of
items returned. To return all items, specify "-ResultSize Unlimited". Be aware that, depending on the actual number of
items, returning all items can take a long time and consume a large amount of memory. Also, we don't recommend storing
the results in a variable. Instead, pipe the results to another task or script to perform batch changes.

$names= Import-Csv c:\temp\name.csv
$Result= @()
$groups= Get-DistributionGroup
foreach ($name in $names) {
foreach($group in $groups){
$members= Get-DistributionGroupmember -ResultSize Unlimited $group
foreach ($member in $members){
if ($member.name -eq $name.name){
$Result1 = New-Object PSObject
$Result1 | Add-Member NoteProperty -Name "User" -Value $name.name
$Result1 | Add-Member NoteProperty -Name "group" -Value $group
$Result += $Result1
}}}}
$Result|Export-csv -Path c:\temp\result.csv -NoTypeInformation


Will the above script work in Exchange Online

· 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,
Test if you get any waring/error again with the following script, in my lab(Ex2016 and Ex online) it;s working fine:

   $names= Import-Csv c:\temp\name.csv
   $Result= @() 
   $groups= Get-DistributionGroup
   foreach ($name in $names) {
   foreach($group in $groups){
   foreach ($member in (Get-DistributionGroupmember $group.name)){
   if ($member.name -eq $name.name){
   $Result1 = New-Object PSObject 
   $Result1 | Add-Member NoteProperty -Name "User" -Value $name.name
   $Result1 | Add-Member NoteProperty -Name "group" -Value $group
   $Result += $Result1
   }}}}
   $Result|Export-csv -Path c:\temp\result.csv -NoTypeInformation


0 Votes 0 ·