PowerShell Snippets for Microsoft Exchange

These are two very handy PowerShell snippets that I use again and again within our work environment.

Retreive List of All Group Members

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
csvde -f C:\report.csv -s -r "memberof=CN=Dept:MyTartgetGroup,OU=Domain Groups,DC=mydomain,DC=ac,DC=uk" -l "sAMAccountName,name, mail"

Retreive List of All Users with Permission to Email a Group

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Get-DistributionGroup "Dept:MyTargetGroup" | Select name,@{Name="AcceptMessagesOnlyFrom";Expression={[string]::join(";",($_.AcceptMessagesOnlyFrom | foreach {$_.Name}))}} | Export-Csv C:\report.csv

Leave a Reply

Your email address will not be published. Required fields are marked *