Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Creating a new user in Azure AD using oneliner PowerShell and Azure CLI

I was testing few Labs on Microsoft Azure active directory and wanted to create few Azure AD users for testing purpose. I have already installed az powershell module, In the below script when you supply password it has to be in securestring format. 

How to switch to other Azure AD tenant using PowerShell and Azure CLI
Powershell Azure Az module Install-Package cannot convert value 2.0.0-preview to type system.version 

#Secret Password
$secureStrPassword = ConvertTo-SecureString -String 'T0p$ecret!' -AsPlainText -Force

#Create User
New-AzADUser -DisplayName DemoUser -UserPrincipalName [email protected] -Password $secureStrPassword -MailNickname DemoUser -ForceChangePasswordNextLogin

If you want to create a user on the Azure Active Directory portal, you can follow below steps on the users | All Users click New user. Provide identity information and click create.

Below script creates bulk users, I am creating 5 users naming starting from User1 to User5 in serial. I am using foreach-object loop to create users.

#Secret Password
$secureStrPassword = ConvertTo-SecureString -String 'T0p$ecret!' -AsPlainText -Force

#Create User
1..5 | % {New-AzADUser -DisplayName "User$_" -UserPrincipalName "[email protected]" -Password $secureStrPassword -MailNickname "User$_" -ForceChangePasswordNextLogin} | Select-Object DisplayName, UserPrincipalName

This is the screenshot after creating bulk users in Azure Active Directory from PowerShell one-liner script.

This example is from Azure CLI command to create Azure AD user.

#Azure CLI command example to create Azure AD user
az ad user create --display-name 'Test User' --password 'T0p$ecret' --user-principal-name [email protected] --force-change-password-next-login true

Useful Articles
CREATE NEW NSG (NETWORK SECURITY GROUP - VIRTUAL FIREWALL ACL) ON MICROSOFT AZURE  
POWERSHELL - EXPORT AZURE NSG (NETWORK SECURITY GROUP) RULES TO EXCEL
MICROSOFT AZURE POWERSHELL: CREATING NEW NSG (NETWORK SECURITY GROUP)
MICROSOFT AZURE POWERSHELL: CLONING (COPING) OR IMPORTING EXISTING NSG (NETWORK SECURITY GROUP) FROM EXCEL
Part 1: Create and deploy a website with Microsoft Azure web app service plan
Part 2: Configure a custom domain in Azure Web Apps
Part 3: Uploading to Azure Web Apps Using FTP
Part 4: Add and manage TLS SSL certificates on Azure Web App



This post first appeared on Tales From Real IT System Administrators World And Non-production Environment, please read the originial post: here

Share the post

Creating a new user in Azure AD using oneliner PowerShell and Azure CLI

×

Subscribe to Tales From Real It System Administrators World And Non-production Environment

Get updates delivered right to your inbox!

Thank you for your subscription

×