Forum Discussion

Ian Moran's avatar
Ian Moran
Steel Contributor
Dec 08, 2016

Assign selective license in Office 365 using Powershell - "Unable to assign this license ..."

I'm attempting to assign Yammer licenses to all users in the tenant who don't have this assigned. All users have location set and have at least an Exchange license from the STANDARDWOFFPACK_FACULTY SKU

 

I'm running the following for one user (as a test) - who doesn't have a Yammer license -  (excludes YAMMER_EDU from the list of licenses) - but it fails with the error message below.

 

Can anyone help please ?

 

PS D:\Office365-Powershell> $MyLicenseOptions = New-MsolLicenseOptions -AccountSkuId "tenantID:STANDARDWOFFPACK_FACULTY" -DisabledPlans FLOW_O365_P2, POWERAPPS_O365_P2, RMS_S_ENTERPRISE, OFFICE_FORMS_PLAN_2, PROJECTWORKMANAGEMENT, SWAY, INTUNE_O365, SHAREPOINTWAC_EDU, MCOSTANDARD, SHAREPOINTSTANDARD_EDU, EXCHANGE_S_STANDARD


PS D:\Office365-Powershell> Set-MsolUserLicense -UserPrincipalName "user@domain.com" -AddLicenses "tenantID:STANDARDWOFFPACK_FACULTY" -LicenseOptions $MyLicenseOptions

 

Set-MsolUserLicense : Unable to assign this license because it is invalid. Use the Get-MsolAccountSku cmdlet to retrieve a list of valid licenses.
At line:1 char:1
+ Set-MsolUserLicense -UserPrincipalName "user@domain.com" -AddL ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Set-MsolUserLicense], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InvalidUserLicenseException,Microsoft.Online.Administration.Automation.SetUserLic
ense

 

PS D:\Office365-Powershell> Get-MsolAccountSku

AccountSkuId ActiveUnits WarningUnits ConsumedUnits
------------ ----------- ------------ -------------
tenantID:STANDARDWOFFPACK_FACULTY 500720 0 760

  • If the user already has the same SKU assigned, you should not use the AddLicenses parameter, only the LicenseOptions one.

    • Ian Moran's avatar
      Ian Moran
      Steel Contributor

      Got it working. This enables all licenses in the SKU while leaving previously assigned licenses untouched.

       

      PS C:\Users\Ian> $MyLicenseOptions = New-MsolLicenseOptions -AccountSkuId "mytenant:STANDARDWOFFPACK_FACULTY" -DisabledPlans $null

       

      PS C:\Users\Ian> PS C:\Users\Ian> Set-MsolUserLicense -UserPrincipalName "user@domain.com" -LicenseOptions $MyLicenseOptions

    • Ian Moran's avatar
      Ian Moran
      Steel Contributor

      Thanks Vasil, tried that by removing that parameter and it actually removed all licenses from the user

       

      Set-MsolUserLicense -UserPrincipalName "user@domain.com" "tenantID:STANDARDWOFFPACK_FACULTY" -LicenseOptions $MyLicenseOptions

Resources