# encoding: ascii
# api: powershell
# title: 
# description: Add new smtp address from csv and set new address primary
# version: 0.1
# license: CC0
# x-poshcode-id: 1713
# x-archived: 2016-05-16T05:36:12
#
#
#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
}
