Explore the docs »
Report Bug
·
Request Feature
This module was written as part of a project to migrate all users to Exchange online. A requirement for this was to have all users email addresses and UPNs match. This script looks up a user based on their SamAccountName or by OU and updates their UPN to match their EmailAddress
To get a local copy up and running follow these simple steps.
- This has been tested in Powershell V5.1 and V7
- Active Directory PowerShell module
- Appropriate domain suffixes configured in Active Directory
- This module is available via the Powershell Gallery
Install-Module -Name Update-UserUPN
- Assuming user Joe Bloggs AD Object looks like this
User UPN Logon - Bloggs.Joe@company.contoso.com
User SamAccountName Logon - domain\bloggs.joe
E-Mail - joe.bloggs@contoso.com
- This will update Joe Bloggs UPN to match his email address but leave his SamAccountName unchanged
Update-UserUPN -SamAccountName bloggs.joe
- This will update the UPN's of all users, in the OU specified, to match their email address
Update-UserUPN -OU "OU=UsersSubOU,OU=Users,DC=company,DC=com"
- This will produce a list of the users current UPN and what their UPN will become (Email Address) should you run either of the above commands, As well as their AD Description (This was more for my benefit and can easily be removed or modified)
Update-UserUPN -OU "OU=UsersSubOU,OU=Users,DC=company,DC=com" -ReportOnly
UserPrincipalName EmailAddress Description
----------------- ------------ -----------
Bloggs.Joe Joe.Bloggs@domain.com Developer
BGatesUPN Bill.Gates@domain.com Developer
APersonUPN Angela.Person@domain.com Developer
Update-UserUPN -SamAccountName bloggs.joe -ReportOnly
UserPrincipalName EmailAddress Description
----------------- ------------ -----------
Bloggs.Joe Joe.Bloggs@domain.com Developer
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request