Skip to content

techbloggingfool.com

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

Tag: Office 365 address policy

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:

  • Share on X (Opens in new window) X
  • Share on Facebook (Opens in new window) Facebook
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Tumblr (Opens in new window) Tumblr

Like this:

Like Loading…
  • October 2026
  • September 2026
  • August 2026
  • July 2026
  • May 2026
  • April 2026
  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • 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

  • Ten Changes to Get the Most Out of Your Lenovo Legion Go
    Ten Changes to Get the Most Out of Your Lenovo Legion Go
  • Deploy a Linux VM on Hyper-V with Sound 20.04 Edition
    Deploy a Linux VM on Hyper-V with Sound 20.04 Edition
  • The Best Pillow Speaker I've Ever Used
    The Best Pillow Speaker I've Ever Used
  • Fixed Moonlight Gamestream Freezing / Locking Up
    Fixed Moonlight Gamestream Freezing / Locking Up
  • Control an Xfinity X1 Cable Box and Other RF Devices with a Samsung Smart One Remote
    Control an Xfinity X1 Cable Box and Other RF Devices with a Samsung Smart One Remote
  • 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
  • Hyper-V NAT: Remote Access to Windows and Linux Virtual Machines
    Hyper-V NAT: Remote Access to Windows and Linux Virtual Machines
  • Fixed Killer Network Manager Launcher Missing Link Error
    Fixed Killer Network Manager Launcher Missing Link Error
  • Turn A PlayStation Vita into the Perfect Game Streaming and Emulation Terminal
    Turn A PlayStation Vita into the Perfect Game Streaming and Emulation Terminal
  • Powershell; Folder Report with File Count and Size
    Powershell; Folder Report with File Count and Size
  1. Dejuan's avatar
    Dejuan on Creative Journaling with Windows Tablets Part 3; Microsoft OnenoteNovember 2, 2026

    That's a really nice article. was searching for Creative Journaling with Windows Tablets and found this

  2. useanytool's avatar
    useanytool on Palworld Tips & Tricks: Co-Op Multiplayer Setup and No Spoilers Review | A Fun Game for Couples and Friends GroupsNovember 1, 2026

    Palworld is definitely one of those games that becomes even more fun with friends. Splitting up tasks like gathering resources,…

  3. useanytool's avatar
    useanytool on Palworld Tips & Tricks: Co-Op Multiplayer Setup and No Spoilers Review | A Fun Game for Couples and Friends GroupsNovember 1, 2026

    Really enjoyed the perspective of playing Palworld as a couple, especially how one person can focus on building and farming…

  4. Bruce Phelps's avatar
    Bruce Phelps on I Swapped My Wedding Band for a Samsung Galaxy Smart RingOctober 29, 2026

    Thanks

  5. Kevin Trent's avatar
    Kevin Trent on I Swapped My Wedding Band for a Samsung Galaxy Smart RingOctober 26, 2026

    I'm still wearing mine. However, you might want to check on the state of the Samsung ring's power issues. I…

Powered by WordPress.com.
Loading Comments...
%d