Connect to Azure AD
Azure AD PowerShell Modunle
You need install MSOnline module only once. In the next time, run to connect to Azure AD PowerShell.
##Connect to MSOnline
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force;
Install-PackageProvider -Name NuGet -Force;
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted;
Install-Module -Name MSOnline;
Connect-MsolService;
![](https://leoguides.com/wp-content/uploads/2022/04/2022-04-05_093529.png)
##Create users
Import-Csv "C:\Temp\Users.csv" |
foreach {New-MsolUser -DisplayName $_.DisplayName -UserPrincipalName $_.UserName -UsageLocation $_.UsageLocation} |
Export-Csv -Path "C:\Temp\Results.csv"
Bulk create users with predefined password
##Create users
$Password = 'LeoGuides@2022'
Import-Csv "C:\Temp\Users.csv" |
foreach {New-MsolUser -DisplayName $_.DisplayName -UserPrincipalName $_.UserName -UsageLocation $_.UsageLocation -Password $Password} |
Export-Csv -Path "C:\Temp\Results.csv"
Bulk create users and assign license
##Create users and assign license
$Password = 'LeoGuides@2022'
$AccountSkuId ='leoguides:DEVELOPERPACK_E5'
Import-Csv "C:\Temp\Users.csv" |
foreach {New-MsolUser -DisplayName $_.DisplayName -UserPrincipalName $_.UserName -UsageLocation $_.UsageLocation -LicenseAssignment $AccountSkuId -Password $Password} |
Export-Csv -Path "C:\Temp\Results.csv"
5/5 - (2 votes)