Hello again PS org family!
Just wanted to get your take on the following and was hoping to obtain some information on how to accomplish my goal.
Thanks as always in advance,
Alex
Goal = Obtain members of a Distribution Group and the members of each nested groups; then export data into a single csv file
Note: Group members will consist of both static and dynamic dgs all nested into the Distribution Group
Issue = Exported data results in multiple csv files, but does contain the correct data
Sample code that produces separate csv files
Write-Output 'Starting Script' # Obtain a Distribution Group data and assign to variable $Dg = Get-DistributionGroup '(DistributionGroupName)' $DgMem = $AllUserWorld | Get-DistributionGroupMember # Loop through each members foreach ($Member in $DgMem){ $Unique = Get-Date -Format yyyymmdd # Check type via switch and process corresponding switch statement Switch ($Member.RecipientType) { # Condition for recipienttype MailUniversalDistributionGroup (static dg) "MailUniversalDistributionGroup"{"$($Member.Name) is a DG" Write-Output "Processing $($Member.Name)" Get-DistributionGroupMember $Member.Name | select @{l='DGName';e={$Member.Name}},name,RecipientType | Export-Csv \\$env:COMPUTERNAME\e$\Temp\$Unique.DG.csv -NoTypeInformation -Append } # end switch statement for MailUniversalDistributionGroup condition # Condition for recipienttype DynamicDistributionGroup (dynamic) "DynamicDistributionGroup"{"$($Member.Name) is a DDG" Write-Output "Processing $($Member.Name)" $DDG = Get-DynamicDistributionGroup $Member.Name Get-Recipient -RecipientPreviewFilter $DDG.RecipientFilter -ResultSize unlimited | select @{l='DDGName';e= {$($DDG.Name)}},name,RecipientType | Export-Csv \\$env:COMPUTERNAME\e$\Temp\$Unique.DDG.csv -NoTypeInformation -Append } # end switch statement for DynamicDistributionGroup } # end switch } # end for each $Member