Forum Discussion
Need to Replace non english characters with english alphabets
Hi Team,
Can someone help me how to replace these characters [ÄäËëÏïÖöóÜüŸßáčďéěíňóřšťúůýž ] with normal English alphabets in on premises Active Directory on UserPrincipalName using PowerShell script? since the these characters are not getting synced with Azure portal.
Ex: need to replace Ä to A, ë to e
I have exported the list of users whose UserPrincipalName has these above unsupported characters but am unable to replace it to normal English alphabets.
Please assist.
Thanks in advance.
- NZScottieCopper Contributor
Give the following a try.
It should be easy to modify with the rest of the characters you require to replace.
I have written it on the fly so the syntax may not be quite correct.
Make sure you run this on a small subset of users or better still some test users before running in production.
# Filter this down to a small set to test with before running over all users in domain. $ADUsers = Get-ADUsers -filter * foreach ($ADUser in $ADUsers) { $NewUPN = $ADUser.UserPrincipalName switch -Regex -CaseSensitive ($ADUser.UserPrincipalName) { 'Ä' { $NewUPN = $NewUPN -replace 'Ä','A' } 'ä' { $NewUPN = $NewUPN -replace 'ä','a' } 'Ë' { $NewUPN = $NewUPN -replace 'Ë','E' } 'ë' { $NewUPN = $NewUPN -replace 'ë','e' } } $ADUser | Set-ADUser -UserPrincipalName $NewUPN }
Let me know how you get on.
- SteveMacNZIron Contributor
Also don't forget about Microsoft Idfix tool https://microsoft.github.io/idfix/
as this will identify, and resolve issues that will effect the sync to Azure AD - been a while since I last used so not sure if it will fix the character replacement issue....
NZScottie script should do the trick to address that.
Would still advise to run Idfix regardless 🙂