Solved

Exchange PowerShell Script

Posted on 2013-11-25
5
343 Views
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.

Regards,

introlux
0
Comment
Question by:introlux
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:Sean
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=Get-DistributionGroup

$Groups| foreach{

$GroupName=$_.Name

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

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

Author Comment

by:introlux
ID: 39674885
error:

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
   alidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
   icrosoft.PowerShell.Commands.ExportCsvCommand
0
 
LVL 9

Accepted Solution

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

$Groups=Get-DistributionGroup

$Groups| foreach{

$GroupName=$_.Name

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


let me know if it still errors out for you.
0
 

Author Comment

by:introlux
ID: 39674936
That worked thanks!
0
 

Author Closing Comment

by:introlux
ID: 39674938
A++
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

809 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