?
Solved

Exchange PowerShell Script

Posted on 2013-11-25
5
Medium Priority
?
351 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
[X]
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
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 2000 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
In this video we show how to create an email address policy 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 Mail Flow…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
Suggested Courses

764 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