Overview
Creating multiple Login VSI users in Azure Active Directory (Azure AD) can streamline account management and improve efficiency, especially in larger organizations. This script allows you to automate the process, saving you time and reducing the risk of manual errors.
Prerequisites
Before running the script in Azure PowerShell, ensure you update the values of the three variables at the top of the script.
Instructions
Change the value for $nrOfUsers, $domain, and $UPN to match your environment.
Script
$nrOfUsers = "4"
$domain = "loginvsi"
$UPN = "@yourdomain.local"
#Make sure you end a password that meets the Azure Password Complexity requirements.
$PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$PasswordProfile.Password = Read-Host "Enter A Complex Password"
Connect-AzureAD
function Get-Usernames {
Param (
[Parameter(Mandatory = $true)]
[int]$start,
[Parameter(Mandatory = $true)]
[string]$end
)
$start..$end | % {
$number = ($start++).ToString(("0").PadLeft($End.Length,'0'))
$name = $domain+ $number
[array]$Counts += $name }
Return $counts
}
foreach ($user in (Get-Usernames -start 1 -end $nrOfUsers)) {
$UserUPN = $User + $UPN
New-AzureADUser -DisplayName "Test User" -PasswordProfile $PasswordProfile -UserPrincipalName $UserUPN -AccountEnabled $true -MailNickName "TestUser"
}