PoshCode Archive  Artifact [35fc035ee5]

Artifact 35fc035ee5eb4e6388e3a3fd449c28d6798748b58cbbbbf9384b565430851966:

  • File setprimaru.ps1 — part of check-in [ed77278247] at 2018-06-10 14:08:59 on branch trunk — Add new smtp address from csv and set new address primary (user: Ermias size: 598)

# encoding: ascii
# api: powershell
# title: setprimaru
# description: Add new smtp address from csv and set new address primary
# version: 0.1
# author: Ermias
# license: CC0
# x-poshcode-id: 6145
# x-archived: 2016-03-18T21:39:49
# x-published: 2016-12-21T19:19: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
}