Hi there .. with this short script you can assign license directly to users from CSV/TXT file.
Prepare CSV file with UserPrincipalName as Header and then save it to your desktop as users.csv
First you need to find out AccountSkuId of a license. We can get it with Get-MsolAccountSku cmdlet.
Then start the script with AccountSkuId as a parameter:
.\AssignLicenseCSV.ps1 reseller-account:POWER_BI_STANDARD
Code language: CSS (css)
Script
param(
[Parameter(Mandatory = $true, Position = 1)]
$script:License
)
Clear-Host
$CSVfile = "$env:USERPROFILE\Desktop\users.csv"
#$License = "reseller-account:POWER_BI_STANDARD" #Power BI (Free)
# IMPORT USERS
Write-Progress -Activity "Importing users.."
$users = Import-Csv $CSVfile
Write-Host $users.count "users were imported." -ForegroundColor Green
Start-Sleep -Seconds 2
# SET LICENSE FOR EACH USER
foreach ($user in $users)
{
$upn = $user.UserPrincipalName
Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses $License
Write-Progress -Activity "Adding licenses.." -CurrentOperation $upn
}
Write-Host "Script done.." -ForegorundColor Green