PoshCode Archive  Artifact [6d3da31767]

Artifact 6d3da31767539fe08558083c2464567b17f9e54aefbb36f55843b08b8171cd5c:

  • File Add-new-smtp-set-prmary.ps1 — part of check-in [873eb1be57] at 2018-06-10 13:23: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: 3289
# x-archived: 2016-05-16T07:27:00
# x-published: 2012-03-15T11:26: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
}