Create Login VSI users in Azure Active Directory in bulk


The following script enables you to create multiple LoginVSI users at once in Azure Active Directory. 

Before running the script in Azure PowerShell make sure to change the values of the 3 variables at the top of the script. 

Change the value behind $nrOfUsers, $domain and $UPN to match your environment. 


$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"


function Get-Usernames {
Param (
[Parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]

$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"