How to change the UPN on Windows domain.
When you are ready to migrate to o365 and realize that your domain is not routable because more than 10 years ago when the domain was created they used .local extension, now a lot of years later you have to fix it.
Another scenario is when the company A acquires Company B and its time to unify everything, you have to change UPN also.
In my opinion is more common the first scenario, the second one is an option though.
The process to complete this setting is as follow:
In your domain controller go to Active Directory Domains and Trusts
Right click on Active Directory domains and trusts and select properties
The UPN suffixes window will appear and here we can add an alternative Suffix as shown below:
Click on Add, then OK to register the alternative domain name.
Now we have another UPN suffix in our domain, we can change this domain name either to specific users or the whole domain users.
In this case lets change to a specific user. To do so, open Active Directory Users and Computers and find a user to change the UPN.
Right click and select properties, then click on Account tab and click on the domain name
As you can see on the figure, now we have available the new domain name, then select the new UPN suffix and click on OK.
Lets validate the change using PowerShell:
As you can see on the UPN attribute, we have now the correct domain name.
So, if you need to change the same for all users in your domain you can do in different ways.
Here you have an script to do so.
# How to change the UPN by Tony Gonzalez
#Lets create a variable to assign the users to affect.
#In case you can modify only few users, you can assign those users to this variable
$Users = Get-ADUser -Properties * -Filter * -SearchBase “OU=UK,DC=TonySolutions,DC=com”
#$Users = Get-ADUser -Properties * -Filter *
Write-Host “The total of users to change the UPN are: $($Users.Count)” -ForegroundColor Yellow
Write-Host “Are you sure to continue? (Y/N)” -ForegroundColor Yellow
$Continue = Read-Host
if($Continue -like ‘y’)
foreach($User in $Users)
$NewUserUPN = $User.UserPrincipalName.Replace(“TonySolutions.com”,”TonyGonzalez0379.com”)
#Notification about the user we are working on
$Name = $User.SamAccountName
Write-Host “Working with $($Name)”
#Applying the change
Set-ADUser $Name -UserPrincipalName $NewUserUPN
#Validating the change
$Sam = $User.SamAccountName
Get-ADUser $Sam -Properties UserPrincipalName
Write-Host “No changes made to the $($Users.Count) Users” -ForegroundColor Green
Thanks for reading!
Everyone has used a lab environment either to test new technologies or to have a safe environment to test scripts or any other configuration, for some hypervisors like VMWare you need to have licenses to use networking devices like switches.
On Oracle VirtualBox you need to have advance networking and Linux skills to create some Virtual machines using Linux as Operating system and then create the routers and switches.
After you have this Linux computers and configure the Switch or router role then configure your internal network.
Another option is creating a Windows server with the NAT role installed, but again we need to create another computer that needs storage on the Hard drive, memory and CPU from the host, sometimes we don’t have enough resources for this.
Fortunately, we have another free option using Hyper-V and creating a NAT switch, in my experience using this option my environment is faster than using another computer as NAT server.
NOTE: If you need help to install the Hyper-V feature on Windows 10 follow this process How to configure Hyper-V on Windows 10
This is my virtual environment with three virtual computers connected to a default switch:
The complete design is as follow:
That means the host cannot provide internet access to the Virtual machines because we are assigning a different IP range.
In order to solve this problem lets create a new virtual switch and configure it as NAT switch.
To complete the configuration open PowerShell ISE as administrator on the host computer.
We are creating the switch as shown below:
The next sped is create the virtual interface for this network
And finally, we need to create the network
Make sure you connect the network interface of the Virtual machines (In my case VM1, VM2, VM3 and VM4) to the NAT Switch, immediately these computers will have internet access.
Thanks for reading!
Now we can use Hyper-V as hypervisor on Widows 10 and its very easy enable this feature. We have different ways to do this, the first its via GUI and the second, of course using PowerShell.
To enable this feature using GUI lets follow these steps:
- From Run menu type control to open control panel
In Control panel go to programs and features
then Turn windows feature on or off
Check Hyper-V and click on Ok
Click on restart and the Hyper-V feature has been added.
Now lets add the same windows feature but using PowerShell, you need to open PowerShell as administrator, then run this line:
PS C:\> Get-WindowsOptionalFeature -Online -FeatureName “*Hyper*” | Enable-WindowsOptionalFeature -Online
And confirm to restart your computer, as shown below:
Thanks for reading and I hope this helps.