Home > Exchange, Exchange 2010, Microsoft, Migration, Other, PowerShell, Scripts > Cleaning up Distribution Lists after a Quest migration

Cleaning up Distribution Lists after a Quest migration


I noticed the other day that the Quest imported DL’s are a tad messy – lots of “userid.postoffice.domain” references.

 

Wrote the following to clean it up – should work without too much butchering into your own environment (but test first!)

 

$list=get-distributiongroup -ResultSize Unlimited
$global:progress = $list.count
foreach($line in $list){
$groupname = get-group $line
$emailaddress = $groupname.DisplayName
$emailaddress = $emailaddress.replace(" ","")

set-distributiongroup -Identity $line.DisplayName -EmailAddressPolicyEnabled $false
set-distributiongroup -Identity $line -SamAccountName $emailaddress -WindowsEmailAddress "$emailaddress@domain.local" -EmailAddresses "$emailaddress@domain.com"
set-distributiongroup -Identity $line.DisplayName -EmailAddressPolicyEnabled $true
$i++
Write-Progress -activity "Changing DL’s" -status "Percent complete: " -percentComplete (($i / $progress)  * 100)    
}

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: