Unable to assign this license

When for example trying to remove the Skype for Business plan, i always get this error:
Skjermbilde 2017-04-09 kl. 21.11.29.png
Same with for example exchange, but for some reason there is no error when doing the same with Yammer.
Any idea?  When trying to manualy remnove exhange from a user in the webportal, i have to remove the LockBox service first.
function disable_skype {
    $users = Get-MsolUser | Where-Object {$_.isLicensed -eq $true}
foreach ($user in $users)
    Write-Host "Checking " $user.UserPrincipalName -foregroundcolor "Cyan"
    $CurrentSku = $user.Licenses.Accountskuid
            #If more than one SKU, Have to check them all!
            if ($currentSku.count -gt 1)
                Write-Host $user.UserPrincipalName "Has Multiple SKU Assigned. Checking all of them" -foregroundcolor "White"
                for($i = 0; $i -lt $currentSku.count; $i++)
                    #Loop trough Each SKU to see if one of their services has the word MCOSTANDARD inside
                    if($user.Licenses[$i].ServiceStatus.ServicePlan.ServiceName -like "*MCOSTANDARD*" )
                        Write-host $user.Licenses[$i].AccountSkuid "has Skype for Business Online. Will Disable" -foregroundcolor "Yellow"
                        $NewSkU = New-MsolLicenseOptions -AccountSkuId $user.Licenses[$i].AccountSkuid -DisabledPlans MCOSTANDARD
                        Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -LicenseOptions $NewSkU
                        Write-Host "Skype for Business disabled for " $user.UserPrincipalName " On SKU " $user.Licenses[$i].AccountSkuid -foregroundcolor "Green"
                        Write-host $user.Licenses[$i].AccountSkuid " doesn't have Skype for Business Online. Skip" -foregroundcolor "Magenta"
                $NewSkU = New-MsolLicenseOptions -AccountSkuId $CurrentSku -DisabledPlans MCOSTANDARD
                Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -LicenseOptions $NewSkU
                Write-Host "Skype for Business Online disabled for " $user.UserPrincipalName -foregroundcolor "Green"
7 Replies

Looks OK to me, but havent run the actual code. I suspect the LicenseOptions variable is somehow broken. What happens if you flip the SfB service for that user by just running the relevant cmdlets outside of the script?

What sound strange to me is what you say about having to disable the lockbox service first in order to remove a EXO license for an existing user

Skjermbilde 2017-04-09 kl. 22.53.42.png

I dont understand it myself, strange. 
Could it be that its a free/trial account? Anyone else testet to run this code in a test enviroment?

Tried to run it for only one user also, same problem.



Dvelve also had to be disabled to disable Exchange in the webportal.

"To assign a lisens that contains Customer Lockboxm you must also assign one of the following services: Exchange Online"

This was the message i got when trying to disable Exchange on a user.

Starting to think this could be a bug?

Skjermbilde 2017-04-09 kl. 23.02.37.png

best response confirmed by Alexander H (MVP)

I think your problem is with the other SfB related services:


[11:47:13][O365]# (Get-MsolAccountSku | ? {$_.AccountSkuId -eq "MOD789510:ENTERPRISEPREMIUM"}).ServiceStatus | ? {$_.ServicePlan.ServiceName -like "MCO*"}

ServicePlan ProvisioningStatus
----------- ------------------
MCOEV       Success


So if you only disable MCOSTANDARD, you get the error. To disable it properly, you need to disable them all:


[11:48:10][O365]# Set-MsolUserLicense -UserPrincipalName -LicenseOptions $newplan
[11:48:14][O365]# (Get-MsolUser -UserPrincipalName

ServicePlan                 ProvisioningStatus
-----------                 ------------------
Deskless                    Success

MCOEV                       Disabled
MCOMEETADV                  Disabled
MCOSTANDARD                 Disabled
SHAREPOINTWAC               PendingInput

Whoops, forgot the serviceplan I used:


$newplan = New-MsolLicenseOptions -AccountSkuId "MOD789510:ENTERPRISEPREMIUM" -DisabledPlans "MCOSTANDARD","MCOEV","MCOMEETADV"

Thanks, that did the trick.

Found that these was needed to disable Exchange:



Found that these was needed to disable SharePoint: