Office 365 Licensing – Enable / Disable Service Plans in PowerShell

Add/Disable Office 365 Licenses With PowerShell

Enter Credentials after Pasting the Code Below in Office365 PowerShell

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

Load the module for the MsolService :

Connect to the Office365 MsolService

Import-Module MSOnline
Connect-MsolService

Find Your License SKU’s

To find out what license SKU’s you have type in the following command in Office365 PowerShell

Get-MsolAccountSku | Format-List –property accountskuid,activeunits,consumedunits

Results:

AccountSkuId : Your_AccountSkuId:AAD_PREMIUM
ActiveUnits : 200
ConsumedUnits : 4
AccountSkuId : Your_AccountSkuId:OFFICESUBSCRIPTION_FACULTY
ActiveUnits : 100
ConsumedUnits : 0
AccountSkuId : Your_AccountSkuId:STANDARDWOFFPACK_FACULTY
ActiveUnits : 300
ConsumedUnits : 0
AccountSkuId : Your_AccountSkuId:ENTERPRISEPACK_FACULTY
ActiveUnits : 300
ConsumedUnits : 274
AccountSkuId : Your_AccountSkuId:POWERAPPS_INDIVIDUAL_USER
ActiveUnits : 100
ConsumedUnits : 1
AccountSkuId : Your_AccountSkuId:STANDARDWOFFPACK_IW_FACULTY
ActiveUnits : 5000
ConsumedUnits : 31
AccountSkuId : Your_AccountSkuId:STANDARDWOFFPACK_IW_STUDENT
ActiveUnits : 10000
ConsumedUnits : 12
AccountSkuId : Your_AccountSkuId:EXCHANGESTANDARD_ALUMNI
ActiveUnits : 100
ConsumedUnits : 23

AccountSkuId:

The “Your_AccountSkuId” before the license name is your “AccountSkuId”, contained within each AccountSkuId are the various Service Plans .

These Service Plan names can be found within the SKU “ENTERPRISEPACK_FACULTY” by using the command below:

Find Service Plan Licenses Withing the SKU

Get-MsolAccountSku | Where-Object {$_.SkuPartNumber -eq “ENTERPRISEPACK_FACULTY”} | ForEach-Object {$_.ServiceStatus}

Results:

ServicePlan ProvisioningStatus
———– ——————
OFFICE_FORMS_PLAN_2 Success
PROJECTWORKMANAGEMENT Success
SWAY Success
INTUNE_O365 Success
YAMMER_EDU Success
RMS_S_ENTERPRISE Success
OFFICESUBSCRIPTION Success
MCOSTANDARD Success
SHAREPOINTWAC_EDU Success
SHAREPOINTENTERPRISE_EDU Success
EXCHANGE_S_ENTERPRISE Success

If you look at your Office365 console the licenses will have the name to the left of the “=” below.

Office 365 ProPlus = OFFICESUBSCRIPTION
Skype for Business Online (Plan 2) = MCOSTANDARD
Office Online for Education = SHAREPOINTWAC
SharePoint Plan 2 for EDU = SHAREPOINTENTERPRISE_EDU
Exchange Online (Plan 2) = EXCHANGE_S_ENTERPRISE
Microsoft Forms (Plan 2) = OFFICE_FORMS_PLAN_2
Microsoft Planner = PROJECTWORKMANAGEMENT
Sway = SWAY
Mobile Device Management for Office 365 ?
Yammer for Academic = YAMMER_EDU
Azure Rights Management = RMS_S_ENTERPRISE

To exclude any of these Service Plans using PowerShell we need to use the Service Plan names above on the right hand side of the = above.

Disable Service Plans

To disable Service Plans run the command below substituting which particular service you want to disable.

First set the variable $x:

$x = New-MsolLicenseOptions -AccountSkuId “Your_AccountSkuId:ENTERPRISEPACK_FACULTY” -DisabledPlans “YAMMER_EDU”, “OFFICE_FORMS_PLAN_2”, “SWAY”, “PROJECTWORKMANAGEMENT”, “INTUNE_O365”, “RMS_S_ENTERPRISE”,”MCOSTANDARD”

Then apply the value of the variable $x to all users:

Get-MsolUser -all | Where-Object {$_.isLicensed -eq $True} | Set-MsolUserLicense -LicenseOptions $x

To add Service Plans back in you can reset the variable $x and apply it to one or all users:

$x = New-MsolLicenseOptions -AccountSkuId “Your_AccountSkuId:ENTERPRISEPACK_FACULTY” -DisabledPlans “YAMMER_EDU”

If the above code was run followed by the code previous to that, all other licenses would be enabled except Yammer.

Remove a Single User’s Service Plan

To remove a single user’s Service Plan(s) run the code below:

Set-MsolUserLicense -UserPrincipalName user@mydomain.com -LicenseOptions $x

Find the Status of a User’s Service Plan

To see the status of a single user’s Service Plan(s) run the code below:

(Get-MsolUser -UserPrincipalName user@mydomain.com).Licenses.ServiceStatus

Restore all Service Plans

To make all licenses available again run the code below:

$x = New-MsolLicenseOptions -AccountSkuId “Your_AccountSkuId:ENTERPRISEPACK_FACULTY” -DisabledPlans $null

Then apply $x to an individual or all users

The commands below assume the value of $x to be “-DisabledPlans $null”

Restore all Service Plans for an Individual

Set-MsolUserLicense -UserPrincipalName user@mydomain.com -LicenseOptions $x

Restore all Service Plans for Everyone

Get-MsolUser -all | Where-Object {$_.isLicensed -eq $True} | Set-MsolUserLicense -LicenseOptions $x

Reference Link Below

https://technet.microsoft.com/library/dn771769.aspx

Sponsors