PoshCode Archive  Artifact [63be3eadb8]

Artifact 63be3eadb8e46798d9bd5d8d165a87dad77e3eb71d02c0b4b9b0c35defc07265:

  • File Add-new-smtp-set-prmary.ps1 — part of check-in [5513110c1d] at 2018-06-10 14:17:22 on branch trunk — Add new smtp address from csv and set new address primary (user: Ermias size: 611)

# encoding: ascii
# api: powershell
# title: Add new smtp/set prmary
# description: Add new smtp address from csv and set new address primary
# version: 0.1
# author: Ermias
# license: CC0
# x-poshcode-id: 6528
# x-archived: 2016-09-27T18:24:56
# x-published: 2016-09-25T01:12: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
}