Hi there

If you don’t have Azure AD P1 or P2 this article it’s addressed to you.

Here you can find what you need to export users’ current license status E1, E3 and ATP and how to assign licenses to them.

First of all, connect to your Office 365 Subscription with the following commands:

Connect-ExchangeOnline
Connect-AzureAD
Connect-MsolService

Then you can list all available licenses available under your Office 365 subscription

Get-MsolAccountSku

Get-AzureADSubscribedSku | Select SkuPartNumber

Retrieving user’s license

Get-MsolUser -UserPrincipalName thiago@thebeier.com | Format-List DisplayName,Licenses

Export to CSV all Enterprise E3 licensed users

Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -match "ENTERPRISEPACK"} | Out-file C:\temp\EnterpriseE3Users.csv

Export to CSV all Standard E1 licensed users

Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -match "STANDARDPACK"} | Out-file C:\temp\StandardE1Users.csv

Export to CSV all Enterprise ATP licensed users

Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -match "ATP_ENTERPRISE"} | Out-file C:\temp\EnterpriseATPUsers.csv

Assigning ATP licenses to E1 and E3 users.

Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -match "ENTERPRISEPACK"} | Set-MsolUserLicense -AddLicenses "tenant:ATP_ENTERPRISE"
Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -match "STANDARDPACK"} | Set-MsolUserLicense -AddLicenses "tenant:ATP_ENTERPRISE"

Assigning ATP licenses to users

#assign license
$userUPN="thiago@thebeier.com"
$planName="ATP_ENTERPRISE"
$License = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
$License.SkuId = (Get-AzureADSubscribedSku | Where-Object -Property SkuPartNumber -Value $planName -EQ).SkuID
$LicensesToAssign = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
$LicensesToAssign.AddLicenses = $License
Set-AzureADUserLicense -ObjectId $userUPN -AssignedLicenses $LicensesToAssign

Tip! – You can assign any license to several users at the same time importing users from a txt or CSV file as well. Download here.

thanks,

Thiago Beier
TwitterLinkedInFacebookRSS