MSExchangeGuru.com

Learn Exchange the Guru way !!!

 

E2K7:Add/Remove email id for bulk users

Create new email address policy and filter with ldap filter but ldap filter will work only if any attribute is common or we will have to write very long ldap query .The solution to this is mentioned below which will be simple 3 step fix:

1. Create Name.ps1 – This will have following 5 line cmds mentioned
———————————————————–
Import-csv “C:emailid.csv” | foreach {
$mailleg = get-mailbox -identity $_.samaccountname
$mailleg.emailaddresses -= $_.mail
$mailleg | set-mailbox
}
————————————————————
There are 2 parameters which can be changed in it.
1. Name of the csv file.
2. In line no 3 use + for adding the email id and for removing the email id.
Add

Import-csv “C:emailid.csv” | foreach {
$mailleg = get-mailbox -identity $_.samaccountname
$mailleg.emailaddresses += $_.mail
$mailleg | set-mailbox
}

Remove

Import-csv “C:emailid.csv” | foreach {
$mailleg = get-mailbox -identity $_.samaccountname
$mailleg.emailaddresses -= $_.mail
$mailleg | set-mailbox
}

2. Create Emailid.csv – This file will have samaccountname and email id of the users. See example.

SamAccountName mail
pn pn@pn.com

3. Run the ps1 file from the exchange shell and done.

Prabhat Nigam
Team@MSExchangeGuru

2 Responses to “E2K7:Add/Remove email id for bulk users”

  1. Wizkid Says:

    For Exchange 2010 the below one is working:
    Import-csv c:\temp\data.csv | ForEach-Object{
    $maileg = $_.Name
    $ProxyAdd = $_.proxyaddresses -split ‘;’
    Set-mailuser -identity $maileg -EmailAddressPolicyEnabled $false -Emailaddresses @{add= $proxyAdd}
    }

  2. Wizkid Says:

    Until I publish new KB for 2010 use this:

    Import-Csv c:\temp\data.csv | Foreach{
    $maileg = Get-Mailuser -Identity $_.Name
    $maileg.EmailAddresses += $_.email -split ‘;’
    $maileg | Set-Mailuser -EmailAddresses $maileg.EmailAddresses
    }

Leave a Reply

migrate exchange to office 365

Categories

Archives