New-MsolUser
Source
Prerequisite
Install PowerShell the Azure Active Directory
Returns all the SKUs for a company.
Get-MsolAccountSku
Download
FirstName,LastName,DisplayName,UserPrincipalName,UsageLocation,AccountSkuId,MobilePhone,PhoneNumber,Title,Department,StreetAddress,PostalCode,City,Office
Edit in Excel save as CSV UFT-8
New-MsolUser.ps1
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (Get-PackageProvider -ListAvailable -Name NuGet -ErrorAction SilentlyContinue) {
Write-Host "NuGet Already Installed"
} else {
try {
Install-PackageProvider -Name NuGet -Confirm:$False -Force
}
catch [Exception] {
$_.message
exit
}
}
if (Get-Module -ListAvailable -Name MSOnline) {
Write-Host "MSOnline Already Installed"
} else {
try {
Install-Module -Name MSOnline -AllowClobber -Confirm:$False -Force
}
catch [Exception] {
$_.message
exit
}
}
Connect-MsolService
Import-Csv -Path "C:\Knowledgebase\New-MsolUser.csv" -delimiter ';' | ForEach {New-MsolUser -FirstName $_.FirstName -LastName $_.LastName -DisplayName $_.DisplayName -UserPrincipalName $_.UserPrincipalName -UsageLocation $_.UsageLocation -LicenseAssignment $_.AccountSkuId -MobilePhone $_.MobilePhone -PhoneNumber $_.PhoneNumber -Title $_.Title -Department $_.Department -StreetAddress $_.StreetAddress -PostalCode $_.PostalCode -City $_.City -Office $_.Office } | Export-Csv -Path "C:\Knowledgebase\Results.csv"
NewPassword.ps1
Import-Csv -Path "C:\Knowledgebase\New-MsolUser.csv" | ForEach {Set-MsolUserPassword -UserPrincipalName $_.UserPrincipalName -NewPassword "Temporary123!" -ForceChangePassword:$false}