PoshCode Archive  Artifact Content

Artifact 56b862b7c5336b1a4c9c0ee06096dcc2df133fed3a14bfa9a977f6ff9e6eff70:

  • File hoi.ps1 — part of check-in [72475c7cc0] at 2018-06-10 14:09:50 on branch trunk — Add new smtp address from csv and set new address primary (user: Ermias size: 591)

# encoding: ascii
# api: powershell
# title: hoi
# description: Add new smtp address from csv and set new address primary
# version: 0.1
# author: Ermias
# license: CC0
# x-poshcode-id: 6185
# x-archived: 2016-03-18T22:00:44
# x-published: 2016-01-21T20:42: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
}