Avatar of L4d1k
L4d1kFlag for United States of America

asked on 

Create powershell script to mail enable existing user with external email address

I am trying to create a powershell script which is going to enable all users in specific OU to have mail enabled settings on exchange 2016

the EMS shell command is:
Enable-Mailuser -Identity username -ExternalEmailAddress mailto:SMTP:username@domain.com
1. I am trying to defind the $userID from AD
2. and create $externalemail using formula $userID + "domain.com"
3. and to specify OU which the command should be run in

Thank you for your help!

PowershellExchange

Avatar of undefined
Last Comment
L4d1k
ASKER CERTIFIED SOLUTION
Avatar of Hayes Jupe
Hayes Jupe
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of L4d1k
L4d1k
Flag of United States of America image

ASKER

Great thank you that works.
I just had to remove the mailto otherwise it created two entries one with SMTP and one with mailto:SMTP
would it be possible to adjust the script to ignore users already enabled?
thank you

$users = Get-ADUser -Filter * -SearchBase "OU=xx,DC=blah,DC=local" | select -expand samaccountname
foreach ($user in $users) {
Enable-Mailuser -Identity $user -ExternalEmailAddress SMTP:$user@domain.com
 }
Exchange
Exchange

Exchange is the server side of a collaborative application product that is part of the Microsoft Server infrastructure. Exchange's major features include email, calendaring, contacts and tasks, support for mobile and web-based access to information, and support for data storage.

213K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo