- PowerShell, with the Azure AD module, allows you to create, update, and delete Azure AD user accounts, making user management more efficient.
- Group creation, membership management, and group-based access control can be easily automated and configured using PowerShell scripts.
- PowerShell is a valuable tool for bulk operations, enabling you to handle multiple users and groups simultaneously.
- It’s important to follow security best practices, protect credentials, and assign proper permissions when using PowerShell with Azure AD.
Step 1 :As a first step open your PowerShell Prompt in your Local machine and select run as Administrator.
Now type the following command
Set-ExecutionPolicy RemoteSigned
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-1024x500.png)
The command Set-ExecutionPolicy RemoteSigned
is a PowerShell command used to set the execution policy for running scripts on a Windows system.RemoteSigned
is one of the execution policies available in PowerShell. When you set the execution policy to RemoteSigned
, it allows the execution of scripts that are local to your computer without requiring a digital signature.
Step 2: Lets install Azure modules to for running our scripts.
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-1.png)
Step 3: Once all the required modules are installed lets connect to our Azure tenant.
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-10.png)
Step 4: Lets get the list of users in the tenant
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-11.png)
Step 5: Lets start creating users for this tenant by using PowerShell.
Type the flowing command below to create a user in Azure AD
New-AzADUser -DisplayName 'Test User01' -UserPrincipalName testuser01@domain-name.onmicrosoft.com -MailNickname test01 `
-Password (Read-Host "Enter the Password for user :" -AsSecureString)
We can also give additional information’s required for the user and run the script to view the user.
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-12-1024x186.png)
We can also provide additional settings, like force the user to change the password once they login.
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-7-1024x165.png)
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-13-1024x211.png)
Step 6: Other simple ways to create a user in Azure AD. Type the command New-AzADuser and fill the parameter’s in the console window.
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-17.png)
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-18.png)
Step 7: Lets edit the properties of a user.
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-19.png)
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-20.png)
Step 8: Lets start creating groups in Azure AD
Check for the available group that exist in your tenant.
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-14.png)
Provide the following commands the create a group in your tenant.
New-AzADGroup -DisplayName Security -MailNickname Security
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-15.png)
Adding members to the group
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-16-1024x254.png)
Step 9: We can also use other ways to create a group using PowerShell. Type New-AzADGroup and run the script, then fill the required parameters for the group.
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-21.png)
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-22.png)
Step 10: Removing or Deleting a group from Azure AD.
![](https://www.azure365pro.com/wp-content/uploads/2023/11/image-23.png)