Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Exchange PowerShell Script

Posted on 2013-11-25
Medium Priority
Last Modified: 2013-11-25
Hi Experts,

Need a script that could do the following:

Scan all distribution groups and list all members email address that is not equal to @domain.com that is associated to that distribution group.

Is this possible and how. Thanks in advance.


Question by:introlux
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 11

Expert Comment

ID: 39674795
Here is a script to get all groups and their members...if you play with it you could probably only get the members you want to but if you only need to run it once i would just use excel to remove the users you don't need.


$Groups| foreach{


$Report+=Get-distributionGroupMember -identity $_.identity| select @{Name='Distribution Group'; Expression={[String]::join(";", $GroupName)}}, Name, PrimarySmtpAddress}

$Report| export-csv "c:\MyFile.csv" -notype

Author Comment

ID: 39674885

Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null
At C:\test.ps1:5 char:20
+ $Report| export-csv <<<<  "c:\MyFile.csv" -notype
    + CategoryInfo          : InvalidData: (:) [Export-Csv], ParameterBindingV
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
LVL 11

Accepted Solution

Sean earned 2000 total points
ID: 39674905
Try and run it without exporting to CSV first:


$Groups| foreach{


Get-distributionGroupMember -identity $_.identity| select @{Name='Distribution Group'; Expression={[String]::join(";", $GroupName)}}, Name, PrimarySmtpAddress}

let me know if it still errors out for you.

Author Comment

ID: 39674936
That worked thanks!

Author Closing Comment

ID: 39674938

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A couple of months ago we ran into an issue that necessitated re-creating our Edge Subscriptions. However, when we attempted to execute the command: New-EdgeSubscription -filename C:\NewEdgeSub_01.xml we received an error indicating that the LDAP se…
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
This video discusses moving either the default database or any database to a new volume.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question