How to assign selective Office 365 license options
You may have users that only require Exchange Online or SharePoint Online or Lync Online. It’s a bit of a chew, but you can assign specific license options from a plan using PowerShell. I’ve already covered bulk licensing to all users and from CSV file in previous posts. Assigning individual services to an MSOL user follows similar steps but is slightly more involved:
1. Log on to a machine that has ‘Microsoft Online Services Module for Windows PowerShell’ installed. You can install this on your own workstation but it should also be installed on your ADFS Servers.
2. Enter the following command and specify credentials for an account that has administrator permissions to your MSOL subscription (such as admin@{tenant_id}.onmicrosoft.com):
$cred = Get-Credential
3. Enter the following command to connect to Microsoft Online Services:
Connect-MsolService -Credential $cred
4. Enter the following command to retrieve your organization’s license details:
Get-MsolAccountSku |ft AccountSkuId,SkuPartNumber
5. Note the AccountSkuId and SkuPartNumber values returned and use in the following steps
6. Note the SkuPartNumber value returned by the previous step and use it in the following command:
$ServicePlans = Get-MsolAccountSku | Where {$_.SkuPartNumber -eq "{SkuPartNumber}"}
For example:
$ServicePlans = Get-MsolAccountSku | Where {$_.SkuPartNumber -eq "ENTERPRISEPACK"}
7. Run the following command:
$ServicePlans.ServiceStatus
All service plans are returned. In the example above, we have the following:
- RMS_S_ENTERPRISE
- OFFICESUBSCRIPTION
- MCOSTANDARD
- SHAREPOINTWAC
- SHAREPOINTENTERPRISE
- EXCHANGE_S_ENTERPRISE
8. We must now create a new license SKU definition that applies only the desired service plans. This is done by disabling the plans we don’t want to apply. Refer back to Step 5 for the required AccountSkuId value and then run the following command:
${NewSkuDefinitionName} = New-MsolLicenseOptions -AccountSkuId {AccountSkuId} -DisabledPlans {Comma_Seperated_List_From_ServicePlans.ServiceStatus_Output}
For example, to create a license SKU definition that only assigns an Exchange Online license I would run the following command to exclude all plans except EXCHANGE_S_ENTERPRISE:
$ExchangeOnlineSku = New-MsolLicenseOptions -AccountSkuId ExitCodeZero:ENTERPRISEPACK -DisabledPlans RMS_S_ENTERPRISE,OFFICESUBSCRIPTION,MCOSTANDARD,SHAREPOINTWAC,SHAREPOINTENTERPRISE
9. Now you can assign the new license SKU definition to users:
a). Assign to individual users:
Set-MsolUser -UserPrincipalName {UserPrincipalName} -UsageLocation {UsageLocation} Set-MsolUserLicense -UserPrincipalName {UserPrincipalName} -AddLicenses {AccountSkuId} -LicenseOptions ${NewSkuDefinitionName}
For example:
Set-MsolUser -UserPrincipalName 365Test1@fqdn.com -UsageLocation GB Set-MsolUserLicense -UserPrincipalName 365Test1@fqdn.com -AddLicenses ExitCodeZero:ENTERPRISEPACK -LicenseOptions $ExchangeOnlineSku
b). Bulk assign using CSV import file:
$AccountSkuId = "{AccountSkuId}" $UsageLocation = "{UsageLocation}" $Users = Import-Csv {CSV_filename} $Users | ForEach-Object { Set-MsolUser -UserPrincipalName $_.UserPrincipalName -UsageLocation $UsageLocation Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $AccountSkuId -LicenseOptions ${NewSkuDefinitionName} }
For example:
$AccountSkuId = "ExitCodeZero:ENTERPRISEPACK" $UsageLocation = "GB" $Users = Import-Csv c:\temp\userlist.csv $Users | ForEach-Object { Set-MsolUser -UserPrincipalName $_.UserPrincipalName -UsageLocation $UsageLocation Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $AccountSkuId -LicenseOptions $ExchangeOnlineSku }
c). Bulk assign to all MSOL users (please proceed with caution):
$AccountSkuId = "{AccountSkuId}" $UsageLocation = "{UsageLocation}" $Users | Get-MsolUser -resultsize unlimited $Users | ForEach-Object { Set-MsolUser -UserPrincipalName $_.UserPrincipalName -UsageLocation $UsageLocation Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $AccountSkuId -LicenseOptions ${NewSkuDefinitionName} }
For example:
$AccountSkuId = "ExitCodeZero:ENTERPRISEPACK" $UsageLocation = "GB" $Users | Get-MsolUser -resultsize unlimited $Users | ForEach-Object { Set-MsolUser -UserPrincipalName $_.UserPrincipalName -UsageLocation $UsageLocation Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $AccountSkuId -LicenseOptions $ExchangeOnlineSku }
Nice Job. Thank you 🙂
Perfect! This really helped me. Just a note, for newbies, don’t type ‘ExitCodeZero’ as part of the SkuID. I did that twice before realizing what I did wrong.