Assigning Licenses in Office 365
Import-Module MSOnline $credential = Get-Credential Connect-MsolService -Credential $credential
Before you can assign a license to a user, you must set the Usage Location for each user – represented by the two-character ISO code for that region.
The Usage Location specifies the country in which the service is to be used, and determines which licensed features are available for that region for example, US is for the United States of America.
Set-MsolUser -UserPrincipalName email@example.com -UsageLocation US
You can now use the Set-MsolUserLicense cmdlet with the -AddLicenses parameter to assign the license, using the appropriate AccountSkuId returned from the previous step.
You must replace firstname.lastname@example.org with the name of the actual user and replace contso with the name of your Office 365 tenant.You must replace email@example.com with the name of the actual user and replace contso with the name of your Office 365 tenant.
Set-MsolUserLicense -UserPrincipalName firstname.lastname@example.org -AddLicenses contoso:ENTERPRISEPACK