Bulk Users Import with Umlauts
Switzerland German, also known as Swiss German or Schwyzerdütsch, is a variety of German spoken in Switzerland. It is a High German language, closely related to standard German, but with a number of distinctive characteristics and dialects. (Bulk Users Import with Powershell)
Table of Contents
In Switzerland German, as in standard German, the umlauts ä, ö, and ü are used to represent certain vowel sounds. The umlauts are written as ae, oe, and ue when the letters are not available, such as in ASCII text or when using certain fonts.
Here are some examples of words with umlauts in Switzerland German:
- Männer (men)
- Möbel (furniture)
- Bücher (books)
In addition to the umlauts, Switzerland German also uses a number of special characters and diacritics, such as the sharp s (ß) and the eszett (ẞ), which is used to represent the sound of the “ss” combination in certain contexts.
To type Switzerland German special characters and umlauts on a computer, you can use the relevant keys on your keyboard or insert the characters using a character map or symbol tool. Some software programs and applications may also provide an option to insert special characters and umlauts using a menu or toolbar.
PowerShell Script with automatic Replacement
Here is an example script which imports users from a CSV file, automatically replaces special characters (umlauts) in the name and automatically records the users in the system. There is also the possibility to add license or other groups. For the import a default password is assigned FirstnamePassword$
<!-- wp:code {"fontSize":"small"} -->
<pre class="wp-block-code has-small-font-size"><code>Function Replace-Umlaut {
param (
[string]$Text
)
# create HashTable with replace map
$characterMap = @{}
$characterMap.([Int][Char]'ä') = "a"
$characterMap.([Int][Char]'ö') = "o"
$characterMap.([Int][Char]'ó') = "o"
$characterMap.([Int][Char]'ü') = "u"
$characterMap.([Int][Char]'ß') = "ss"
$characterMap.([Int][Char]'Ä') = "A"
$characterMap.([Int][Char]'Ü') = "U"
$characterMap.([Int][Char]'Ö') = "O"
$characterMap.([Int][Char]'é') = "e"
$characterMap.([Int][Char]'ë') = "e"
$characterMap.([Int][Char]'è') = "e"
$characterMap.([Int][Char]'á') = "a"
$characterMap.([Int][Char]' ') = "-"
# Replace chars
ForEach ($key in $characterMap.Keys) {
$Text = $Text -creplace ([Char]$key),$characterMap[$key]
}
# return result
$Text
}
# Define Paramaters
$strAdmin = "administrator@TENANT.onmicrosoft.com"
$Directory = "edu.DOMAIN"
$CsvFilePath = "./Users.csv"
# Login zu AzureAD
$cred = Get-Credential -UserName $strAdmin -Message "Login to AzureAD"
Connect-AzureAD -Credential $cred
# Get the CSV
$NewUsers = import-csv -Path $CsvFilePath -Encoding Default #CSV Westeurop ischen Context Encoded
# Get Groups
$AAD_LIC_Users = Get-AzureADGroup -SearchString "LIC_Users"
$AAD_PersonalOwnedUsers = Get-AzureADGroup -Filter "DisplayName eq 'AAD_Users'"
# Loop trough all Users
ForEach ($u in $NewUsers) {
$UserPrincipalName = Replace-Umlaut($u.Firstname + "." + $u.LastName + "@" + $Directory)
$DisplayName = $u.Firstname + " " + $u.Lastname
$MailNickName = Replace-Umlaut($u.Firstname + "." + $u.LastName)
$PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$DefaultPw = "$(Replace-Umlaut($u.Firstname))Password$"
$PasswordProfile.Password = $DefaultPw
Write-Host $UserPrincipalName " - " $DisplayName " - " $u.FirstName " - " $u.LastName " - " $MailNickName " - " $PasswordProfile
try {
New-AzureADUser -UserPrincipalName $UserPrincipalName -AccountEnabled $true -DisplayName $DisplayName -GivenName $u.FirstName -Surname $u.LastName -MailNickName $MailNickName -PasswordProfile $PasswordProfile
} catch {
Write-Host "Already Exist or Error `r`n $_.Exception.Message"
}
$ADuser = Get-AzureADUser -ObjectId "$UserPrincipalName"
try {
#Assign Groups to new User
Add-AzureADGroupMember -ObjectId $AAD_PersonalOwnedUsers.ObjectID -RefObjectId $ADuser.ObjectID
Add-AzureADGroupMember -ObjectId $AAD_LIC_Users.ObjectID -RefObjectId $ADuser.ObjectID
} catch {
Write-Host "User is already in Group"
}
}</code></pre>
<!-- /wp:code -->
How does the CSV File looks like
Lastname,Firstname
Gamper,Hans
Kàttel,Jannik
Merkurt,Damian
Lüönd,Kim
Otter,Remo
Bärgler,Maria
Inderbitzin,Karl
Jöckel,Lim
Küttel,Sia
Rebelo dos Santos,Kurt
Kircimi,ézden
Conclusion
There are a few reasons why you might want to import Azure AD users using PowerShell:
- Efficient bulk user management: If you have a large number of users to manage, using PowerShell can be more efficient than manually creating each user in the Azure AD portal.
- Automation: You can use PowerShell scripts to automate the process of importing users, which can save time and reduce the potential for errors.
- Customization: Using PowerShell allows you to customize the import process to meet your specific needs. For example, you can use PowerShell to assign specific roles or groups to users as part of the import process.
- Integration with other systems: If you have a system that generates user information (such as an HR database), you can use PowerShell to integrate with that system and import the user information automatically.
Overall, using PowerShell to import Azure AD users can be a useful tool for efficiently managing and automating the process of creating and maintaining users in your Azure AD tenant.