Adding/removing users via PowerShell in AAD
This recipe should begin to get you thinking about how you could potentially automate regular processes in your organization by utilizing PowerShell as part of your automated job. While we'll manually add a user to Azure AD in this recipe, you could have the same PowerShell script run based on a trigger from your HR system, by way of an example. For now, we'll start with the basics – running the script itself manually to add a user.
You must be a global administrator to complete the steps in this recipe.
How to do it…
- Open Windows PowerShell (or your PowerShell client of choice) as the administrator.
- Connect to Azure AD using
- Use a script such as the following, replacing the user's specific info where appropriate.
$PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile $PasswordProfile.Password = "aBc123!ndc" New-AzureADUser...