What I'm looking to do here is assign specific licenses to specific accounts, that is pulled from a csv file. I have some scripts where I can bulk assign but only one license type at a time. What I'm looking to have is more granular control and bulk assign multiple license types off a csv that is something like this:
upn | license type |
---|---|
testuser1@testdomain.com | Microsoft 365 E3 |
testuser2@testdomain.com | Microsoft 365 E5 |
testuser3@testdomain.com | Microsoft 365 E3 |
testuser4@testdomain.com | Microsoft 365 F3 |
upn (userprincipalname) and license type are the column headers).Where each specified user is assigned that specific license in it's row.
So as I understand, I can do:
Get-MsolAccountSku
Which will give me all my existing license types, I can take note of the SkuId for the specific license I need, lets say for example it's testtenant:SPE_E3 , I can then do something like:
users = import-csv ".\bulkassignlicenses.csv"
foreach ($user in $users)
{
$upn=$user.UserPrincipalName
$SKU= "testtenant:SPE_E3"
Set-MsolUser -UserPrincipalName $upn
Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses $SKU
Write-Host "License Assigned to UPN:"$upn
}
Issue is this will only assign one type of license to the listed users in the csv file and I can't figure out how to make it iterate through a CSV and assign different types of licenses.