Create Azure AD user with PowerShell

Posted: December 5, 2016 in Azure

In one of my previous posts we created user in Azure portal.On of the drawback of this approach is that user is created with a temporary password and the user must log in to set a new one.

Download and install Microsoft Online Services Sign-In Assistant for IT Professionals RTW and Azure Active Directory Module for Windows PowerShell (64-bit version)

Run Windows Azure Active Directory Module for Windows PowerShell

Untitled.png

Put credentials of Global Admininstrator user.This has to be non-microsoft account !!

$msolcred = Get-Credential

capture

Connect to Azure:

Connect-MsolService -Credential $msolcred

Create user:

New-MsolUser -UserPrincipalName admin01@bigfirm.info -DisplayName "admin01" -FirstName "Peter" -LastName "Parker" -Password Password00 -PasswordNeverExpires $true -AlternateEmailAddresses spiderman@bigfirm.info

capture

By Default,this new user has user role

Capture.PNG

To see all available roles with description run next cmdlet:

Get-MsolRole | ft -Wrap

Capture.PNG

Assigning role to user:

Add-MsolRoleMember -RoleName "Company Administrator" -RoleMemberEmailAddress admin01@bigfirm.info
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s