PoshCode Archive  Artifact Content

Artifact 6c01526cb3db9c3849aa0794106a2463a6f139bdc4c5ddcff8f6c9718f5ab298:

  • File target-local.ps1 — part of check-in [d95871d728] at 2018-06-10 13:13:29 on branch trunk — Add new smtp address from csv and set new address primary (user: Ermias size: 600)

# encoding: ascii
# api: powershell
# title: target.local
# description: Add new smtp address from csv and set new address primary
# version: 0.1
# author: Ermias
# license: CC0
# x-poshcode-id: 2634
# x-archived: 2016-05-16T10:23:34
# x-published: 2011-04-26T10:37: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
}