Create on-cloud user for specific domain - Custom action

  • Last update on January 25th, 2024

If you are looking for a way to create cloud user for a specific domain you can use the following:

Please note the following:

  • Variable set as input in the Custom action
  • Domain can't be change by the Operator (restricted by the script)

Sample Script:

$UserPincipalName = $UPN+'@M365x795031.OnMicrosoft.com'
$PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$PasswordProfile.Password = $Password
New-AzureADUser -DisplayName $DisplayName -PasswordProfile $PasswordProfile -UserPrincipalName $UserPincipalName -AccountEnabled $true -MailNickName $UPN