Hi Readers,

 

I am sharing a script that has been written to analyze how many distribution groups are there in the organization,

count of members & whether it is restrictedor not.

It can run with both exchange 2007 & exchange 2010 just change the Shell in the script:

for 2007:

If ((Get-PSSnapin | where {$_.Name -match "Exchange.Management"}) -eq $null)

{

 Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

}

for 2010:

If ((Get-PSSnapin | where {$_.Name -match "Microsoft.Exchange.Management.PowerShell.E2010"}) -eq $null)


{

 Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010

}

Sample report:-

Powershell

reachme:- http://techwizard.cloud

 

  

 

PowerShell
Edit|Remove
############################################################################# 
#       Author: Vikas Sukhija 
#       Date: 10/29/2013 
#       Description: Dl number of members report 
############################################################################# 
 
If ((Get-PSSnapin | where {$_.Name -match "Microsoft.Exchange.Management.PowerShell.E2010"}) -eq $null) 
 
{ 
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 
} 
 
 
#format Date 
 
$date = get-date -format d 
$date = $date.ToString().Replace(“/”, “-”) 
 
$output = ".\" + "DL_Reprt_" + $date + "_.csv" 
 
$Collection = @() 
$a = Get-DistributionGroup -resultsize unlimited  
$a | foreach-object{ 
if($_.AcceptMessagesOnlyFrom -ne $null) 
{$restriction = "Yes"else 
{$restriction = "NO"$members = Get-DistributionGroupMember $_.identity -resultsize unlimited 
$countmem = $members.count 
 
$memb = “” | select Name, SamaccountName,CountMembers,restricted 
  
$memb.Name = $_.Name 
$memb.SamaccountName = $_.SamaccountName 
$memb.CountMembers = $countmem 
$memb.restricted = $restriction 
$Collection +$memb 
 
} 
 
########################Export Collection###################################### 
 
$Collection | export-csv $output 
 
###############################################################################

 

 

Thanks for reading and downloading

Tech Wizard

http://techwizard.cloud

PowerShell Cheat Book