Forum Discussion

AlexanderHolmeset's avatar
Apr 09, 2017
Solved

Unable to assign this license

When for example trying to remove the Skype for Business plan, i always get this error:
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"
                        }
                    else
                        {
                        Write-host $user.Licenses[$i].AccountSkuid " doesn't have Skype for Business Online. Skip" -foregroundcolor "Magenta"
                        }
                }
            }
            else
            {
                $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"
            }
}
}
  • VasilMichev's avatar
    VasilMichev
    Apr 10, 2017

    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
    MCOMEETADV  Success
    MCOSTANDARD 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 LidiaH@MOD789510.onmicrosoft.com -LicenseOptions $newplan
    [11:48:14][O365]# (Get-MsolUser -UserPrincipalName LidiaH@MOD789510.onmicrosoft.com).licenses.servicestatus

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

    LOCKBOX_ENTERPRISE          Success
    EXCHANGE_ANALYTICS          Success
    MCOEV                       Disabled
    MCOMEETADV                  Disabled
    MCOSTANDARD                 Disabled
    EXCHANGE_S_ENTERPRISE       Success
    SHAREPOINTENTERPRISE        PendingInput
    SHAREPOINTWAC               PendingInput

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?

    • 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.

       

       

    • 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
      • AlexanderHolmeset's avatar
        AlexanderHolmeset
        MVP

        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?

Resources