Skip to content

techbloggingfool.com

  • Home
  • Gear
  • Microsoft
  • Linux
  • Apple
  • Networking
  • Gaming
  • Digital Notes
  • The Buzz
  • About
  • Contact

Tag: PowerShell Email Addresses

PowerShell; Build Azure AD Connect Email Addresses without a local Exchange Server

August 20, 2019Posted in MicrosoftTagged Automate Office 365 Email Addresses, Exchange On-line Addresses, Office 365 address policy, Office 365 email address policy, Office 365 Migration, PowerShell Email Addresses, Script Email AddressesLeave a comment

Not long ago I needed to change a company’s email address format from first initial last name@company.com (flast@company.com) to first name.last name@company.com (first.last@company.com). There were several hundred user accounts in the on-premises Active Directory. The local AD was being synchronized to Office 365 with Azure AD Connect.

Typically, an environment like this might have a stripped-down Exchange server configured for a hybrid federation with Office 365 to get access to the ECP (Exchange Control Panel). Having the ECP would have allowed me to use an address policy to solve this dilemma. However, this environment did not have such an option. Their available compute resources prevented the creation of a Exchange management server, so another solution was required.

As usual, I turned to PowerShell. I needed to use the name data in Active Directory to construct the email address. Then I had to insert the addresses into the ProxyAddress field so that they would be synchronized with the Office 365 mailboxes. Below is the code I came up with for accomplishing my goal.

Import-Module ActiveDirectory

$users = Get-ADUser -Filter * -SearchBase ("ou=users,dc=mydomain,dc=local")|select SammAccountName, Givenname, Surname

Foreach ($user in $users) 
{
     [string]$newproxyAddress = "SMTP:" + $user.Givenname + "." + 
     $user.Surname + "@" + "mydomain.com" 

     Set-ADUser -Identity $user.SamAccountName -Add 
     @{Proxyaddresses=$newproxyaddress}
}

This same code could easily be used to remove addresses by changing the -Add to -Remove. If you’re adding more than one address, the one labeled with a capital SMTP: will be the primary address. Set the others as a lowercase smtp:.

It worked like a charm. I ended up using this little snippet to build and insert three additional addresses for each of the users. In fact, it works so well, I will probably stop building Exchange servers in the local domain for managing email addresses and distribution lists.

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Tumblr (Opens in new window) Tumblr
Like Loading...
  • November 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017

Top Posts & Pages

  • Fixed Killer Network Manager Launcher Missing Link Error
    Fixed Killer Network Manager Launcher Missing Link Error
  • Ten Changes to Get the Most Out of Your Lenovo Legion Go
    Ten Changes to Get the Most Out of Your Lenovo Legion Go
  • Starfield, After the Fixes and DLC. A No Spoilers Review
    Starfield, After the Fixes and DLC. A No Spoilers Review
  • Digital Art and the XP-Pen Artist 15.6 drawing monitor
    Digital Art and the XP-Pen Artist 15.6 drawing monitor
  • Fix For Intel i225-V Ethernet Controller Dropping Connections with Event ID 27 e2fnexpress
    Fix For Intel i225-V Ethernet Controller Dropping Connections with Event ID 27 e2fnexpress
  • Deploy a Linux VM on Hyper-V with Sound 20.04 Edition
    Deploy a Linux VM on Hyper-V with Sound 20.04 Edition
  • Hogwarts Legacy, A Game Worth Finishing (No Spoilers Review)
    Hogwarts Legacy, A Game Worth Finishing (No Spoilers Review)
  • Fixed Moonlight Gamestream Freezing / Locking Up
    Fixed Moonlight Gamestream Freezing / Locking Up
  • Couch Gaming Perfection with the Logitech Lightspeed G915TKL Keyboard and G502 Mouse
    Couch Gaming Perfection with the Logitech Lightspeed G915TKL Keyboard and G502 Mouse
  • PowerShell: Backup and Repair/ Reset Windows Update.
    PowerShell: Backup and Repair/ Reset Windows Update.
  1. CJE's avatar
    CJE on Fixed Killer Network Manager Launcher Missing Link ErrorDecember 15, 2025

    You are a hero, thank you!

  2. suwaidionline's avatar
    suwaidionline on Ten Changes to Get the Most Out of Your Lenovo Legion GoDecember 12, 2025

    Love the practical tips on sound, updating, controls, GPU upscaling, and SSD upgrades super helpful for squeezing every bit of…

  3. suwaidionline's avatar
    suwaidionline on How to choose a Gaming Laptop; Lenovo Y700 ReviewDecember 12, 2025

    This gaming laptop guide + Lenovo Y700 review clearly explains how to pick the right specs (CPU, RAM, storage, GPU)…

  4. Yvan's avatar
    Yvan on Fixed Killer Network Manager Launcher Missing Link ErrorDecember 11, 2025

    I find myself today with the same problem. Surprised, I asked myself how this program got installed, because I didn’t…

  5. philippemp31's avatar
    philippemp31 on Fixed Killer Network Manager Launcher Missing Link ErrorDecember 2, 2025

    Thank you , it worked great !

Website Powered by WordPress.com.

Top Posts & Pages

  • Fixed Killer Network Manager Launcher Missing Link Error
  • Ten Changes to Get the Most Out of Your Lenovo Legion Go
  • Starfield, After the Fixes and DLC. A No Spoilers Review
  • Digital Art and the XP-Pen Artist 15.6 drawing monitor
  • Fix For Intel i225-V Ethernet Controller Dropping Connections with Event ID 27 e2fnexpress
  • Deploy a Linux VM on Hyper-V with Sound 20.04 Edition
  • Hogwarts Legacy, A Game Worth Finishing (No Spoilers Review)
  • Fixed Moonlight Gamestream Freezing / Locking Up
  • Couch Gaming Perfection with the Logitech Lightspeed G915TKL Keyboard and G502 Mouse
  • PowerShell: Backup and Repair/ Reset Windows Update.
  • Subscribe Subscribed
    • techbloggingfool.com
    • Join 175 other subscribers
    • Already have a WordPress.com account? Log in now.
    • techbloggingfool.com
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
%d