PoshCode Archive  Artifact Content

Artifact a4725843fb966bd7619de8638f491be70e2a69f4e8e996efdbf94604b9f69149:

  • File dir-mus-com-net.ps1 — part of check-in [cf182435d1] at 2018-06-10 13:48:52 on branch trunk — Add new smtp address from csv and set new address primary (user: Ermias size: 603)

# encoding: ascii
# api: powershell
# title: dir.mus@com.net
# description: Add new smtp address from csv and set new address primary
# version: 0.1
# author: Ermias
# license: CC0
# x-poshcode-id: 5023
# x-archived: 2014-03-30T06:47:06
# x-published: 2014-03-26T13:03:00
#
#
#alias,addnewemailaddress

import-csv .\source.csv | foreach {
$user = Get-Mailbox $_.alias
$user.emailAddresses+= $_.addnewemailaddress
$user.primarysmtpaddress = $_.addnewemailaddress
Set-Mailbox $user -emailAddresses $user.emailAddresses
set-Mailbox $user -PrimarySmtpAddress $user.primarysmtpaddress
}