MSExchangeGuru.com

Learn Exchange the Guru way !!!

 

E2010: Add/Remove email id for bulk users

Three step solution to add or remove multiple email addresses

1. Create Name.ps1 – This will have following 5 line cmds mentioned
————————————————————————————————————————
Import-Csv c:tempdata.csv | Foreach{

$maileg = Get-Mailbox -Identity $_.Name

$maileg.EmailAddresses += $_.email -split ‘;’

$maileg | Set-Mailbox -EmailAddresses $maileg.EmailAddresses

}

————————————————————————————————————————
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:tempdata.csv | Foreach{

$maileg = Get-Mailbox -Identity $_.Name

$maileg.EmailAddresses += $_.email -split ‘;’

$maileg | Set-Mailbox -EmailAddresses $maileg.EmailAddresses

}

Remove

Import-Csv c:tempdata.csv | Foreach{

$maileg = Get-Mailbox -Identity $_.Name

$maileg.EmailAddresses -= $_.email -split ‘;’

$maileg | Set-Mailbox -EmailAddresses $maileg.EmailAddresses

}

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

Name,email

pn,smtp:pn@pn.com;SMTP:Prabhat@pn.com

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

C:temp>Name.ps1

Prabhat Nigam
Team@MSExchangeGuru

4 Responses to “E2010: Add/Remove email id for bulk users”

  1. Aubrey Says:

    I have searched high and low and can not find a delete bulk mailbox with powershell example. I have been trying to put it together from several other examples but no luck do far. Here is a sample of what I have tried:

    [PS] C:\>$mb = Get-Mailbox -Database qt-mbx-cls.oberonmedia.local\china | select
    Alias | Remove-Mailbox -Identity Alias -Permanent $true -Confirm:$false -whatif

    I have also tried various foreach loops, but just get errors

    Any help is greatly appreciated!

  2. Aubrey Says:

    Answer here: http://randomtechminutia.wordpress.com/2012/05/03/powershell-script-to-delete-exchange-mailboxes-in-mass/

  3. Prabhat Says:

    This is a tested PS.1 script so it can’t be wrong.
    I will be interested in checking your errors.

  4. Sony Says:

    Thank you for this fix.

Leave a Reply

Categories

Archives

MSExchangeGuru.com