Wednesday, November 6, 2013

Distribution Groups Report - Exchange 2007/2010

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:-


Power-shell Script Download from here


reach me:- http://msexchange.me


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 = @() 
Get-DistributionGroup -resultsize unlimited | 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 
 
###############################################################################
 

Regards

Sukhija Vikas

No comments:

Post a Comment