PoshCode Archive  Artifact [c506fd4cb5]

Artifact c506fd4cb5e90ad330f059c5329d65cd8c98fd7973110d55aa2211ce1af7892e:

  • File Add-new-smtp-set-prmary.ps1 — part of check-in [3e34dd5140] at 2018-06-10 14:21:23 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: 6825
# x-archived: 2017-04-01T14:36:31
# x-published: 2017-03-29T14:41: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
}