'Assign multiple o365 licenses to a single user using PowerShell

I'm using a simple Powershell script to add new users to O365 and assign a license. However im trying to add multiple licenses at once to a single user.

Powershell

Connect-MsolService -Credential $UserCredential

Import-Csv -Path "C:\Users\Jesse\Documents\Powershell\NewAccounts.csv" | foreach {New-MsolUser -DisplayName $_.DisplayName -FirstName $_.FirstName -LastName $_.LastName -UserPrincipalName $_.UserPrincipalName -UsageLocation $_.UsageLocation -LicenseAssignment $_.AccountSkuId} | Export-Csv -Path "C:\Users\Jesse\Documents\Powershell\NewAccountResults.csv" -Verbose

.CSV

DisplayName,FirstName,LastName,UserPrincipalName,Usagelocation,AccountSkuId
Test Jesse,Tes,Jesse,test.jesse@(tenant).nl,NL,(tenant):EMS

For this example i'd like to add the EMS & ENTERPRISEPACK license to the test user.



Solution 1:[1]

I use a simple script to add multiple licenses. Only information needed is the UPN, which in my environment is the mail address.

Connect-MsolService
Import-Csv 'C:\usersmailaddress.CSV' | foreach {Set-MsolUser -UserPrincipalName $_.EmailAdress -UsageLocation BR
Set-MsolUserLicense -UserPrincipalName $_.EmailAdress -AddLicenses mydomain:ENTERPRISEPACK
Set-MsolUserLicense -UserPrincipalName $_.EmailAdress -AddLicenses mydomain:EMS
}

You can adapt it to your needs.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeremy Caney