New-MsolUser
Source
Prerequisite
Install PowerShell the Azure Active Directory
Returns all the SKUs for a company.
1 |
Get-MsolAccountSku |
Download
1 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
[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
1 |
Import-Csv -Path "C:\Knowledgebase\New-MsolUser.csv" | ForEach {Set-MsolUserPassword -UserPrincipalName $_.UserPrincipalName -NewPassword "Temporary123!" -ForceChangePassword:$false} |