PowerShell Basics: How To Add A New Azure Active Directory User

Published Feb 25 2020 12:01 AM 8,323 Views

Our team has been receiving a large number of questions in the Microsoft Ignite the Tour Experts area regarding the adoption of Azure Active Directory.  One question that comes up frequently is:


"How do I automate the ability to add Azure Active Directory users outside of using Azure Portal?"


This post will detail steps in adding Azure Active Directory users via PowerShell via the simplest way possible allowing others to include the following steps into their automation scripts. 


Lets get started.


  1. Run PowerShell
    Run PowerShell Force AzureAD Password SyncRun PowerShell Force AzureAD Password Sync 
  2. Run the following command to install the Active Directory module:
    Install-Module ActiveDirectory

    Or confirm the module is loaded using the following command:

    Get-Module ActiveDirectory


  3. Next lets connect to your instance of Azure:


  4. Confirm the connection is established and you are attached to the desired AzureAD instance using the following command:



  5. With the connection now confirmed, we now need to generate a password profile object and set the properties of that object via the following command:
    $PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
    $Passw0rdProfile.Password = "IT0psT@lk"
  6. Next we'll assign the parameters for the Get-User command:

    $params = @{
    AccountEnabled = $true
    DisplayName = "Mike Finnegan"
    PasswordProfile = $PasswordProfile
    UserPrincipalName = "FwF@Motor.onmicrosoft.com
    MailNickName = "Finnegan"
    NOTE: It is best practice to pass parameters to a cmdlet when you are assigning more than 2 parameters.  This makes it easier to see what parameters need to be assigned to the new user.  The above are the minimal parameters we need to assign to create the user.

  7. Lets now create the new user including the parameters that were previously assigned:

    New-AzureADUser @params
  8. Finally we'll confirm the user has been created via the following command:



There are other ways to add users to Azure Active Directory and MS Learn has a great learning module entitled Create Azure users and groups in Azure Active Directory. Be sure to also share your scripting tips in the comments below.

Version history
Last update:
‎Feb 23 2020 10:24 AM
Updated by: