Showing posts with label get distribution group owner powershell. Show all posts
Showing posts with label get distribution group owner powershell. Show all posts

Tuesday 25 October 2016

How to export the exception members list of a Moderated DL in Office356 server?

Or, PowerShell command to export the exception list of a moderated DL in Office365 server.

Descriptions: If you have enabled moderation on some sensitive DLs and want to verify who all are excluded from being moderated, you can use below PowerShell command to export the list of exceptions defined under DL moderation settings.

Steps:
Connect to office365 server PowerShell admin console with administrative privilege.
Run below command to get the list:

Get-DistributionGroup -Identity "MyModeratedDLName" | Select-Object bypass* |Export-Csv D:\list.csv

Note: you can replace the ‘MyModeratedDLName’ with your moderated DL name as per your requirements. Also, you can specify the export path as per your convenient.

Exporting DLs with Last modify date, Date created, DL members, Members display name etc. Details in Office365 server using PowerShell.

Or, PowerShell script to export DLs in Office365 server containing details like Last Modify, Date Created, DL Members, Members Display Name, Owners etc...

Descriptions: Sometime you may need to export the DLs with their last modify date, members list and creation date for audit or inventory purpose.  You can use below PowerShell command to get these details exported in an .CSV file.

Note: Please understand the risk before executing any commands/scripts.

Steps:
Login to Office365 Server Admin PowerShell Console with administrative rights.

Copy all script section contents and run that on powershell to get the DLs details as explained above. You can change the yellow marked path and file name if you want results to be exported to some other path and with some other file name as per your requirements.

-----------------------------------------------------------------------------------------------------------------------
#Prepare Output file with headers
Out-File -FilePath d:\new.csv -InputObject "Distribution Group DisplayName,Distribution Group Email,When Created,Last Modified,Owner,Member DisplayName, Member Email, Member Type" -Encoding UTF8


#Get all Distribution Groups from Office 365
$objDistributionGroups = Get-DistributionGroup -ResultSize Unlimited

#Iterate through all groups, one at a time    
Foreach ($objDistributionGroup in $objDistributionGroups)
{    
               
                write-host "Processing $($objDistributionGroup.DisplayName)..."

                #Get members of this group
                $objDGMembers = Get-DistributionGroupMember -Identity $($objDistributionGroup.PrimarySmtpAddress)
                
                write-host "Found $($objDGMembers.Count) members..."
                
                #Iterate through each member
                Foreach ($objMember in $objDGMembers)
                {
                                Out-File -FilePath d:\new.csv -InputObject "$($objDistributionGroup.DisplayName),$($objDistributionGroup.PrimarySMTPAddress),$($objDistributionGroup.WhenCreated),$($objDistributionGroup.WhenChanged),$($objDistributionGroup.Managedby),$($objMember.DisplayName),$($objMember.PrimarySMTPAddress),$($objMember.RecipientType)" -Encoding UTF8 -append
                                write-host "`t$($objDistributionGroup.DisplayName),$($objDistributionGroup.PrimarySMTPAddress),$($objDistributionGroup.WhenCreated),$($objDistributionGroup.WhenChanged),$($objDistributionGroup.Managedby),$($objMember.DisplayName),$($objMember.PrimarySMTPAddress),$($objMember.RecipientType)"
                }
}
-----------------------------------------------------------------------------------------------------------------------