Home

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

%3CLINGO-SUB%20id%3D%22lingo-sub-34699%22%20slang%3D%22en-US%22%3EAssign%20selective%20license%20in%20Office%20365%20using%20Powershell%20-%20%22Unable%20to%20assign%20this%20license%20...%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34699%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20attempting%20to%20assign%20Yammer%20licenses%20to%20all%20users%20in%20the%20tenant%20who%20don't%20have%20this%20assigned.%20All%20users%20have%20location%20set%20and%20have%20at%20least%20an%20Exchange%20license%20from%20the%20STANDARDWOFFPACK_FACULTY%20SKU%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20running%20the%20following%20for%20one%20user%20(as%20a%20test)%20-%20who%20doesn't%20have%20a%20Yammer%20license%20-%20%26nbsp%3B(excludes%20YAMMER_EDU%20from%20the%20list%20of%20licenses)%20-%20but%20it%20fails%20with%20the%20error%20message%20below.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20anyone%20help%20please%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPS%20D%3A%5COffice365-Powershell%26gt%3B%20%3CSTRONG%3E%24MyLicenseOptions%20%3D%20New-MsolLicenseOptions%20-AccountSkuId%20%22tenantID%3ASTANDARDWOFFPACK_FACULTY%22%20-DisabledPlans%20FLOW_O365_P2%2C%20POWERAPPS_O365_P2%2C%20RMS_S_ENTERPRISE%2C%20OFFICE_FORMS_PLAN_2%2C%20PROJECTWORKMANAGEMENT%2C%20SWAY%2C%20INTUNE_O365%2C%20SHAREPOINTWAC_EDU%2C%20MCOSTANDARD%2C%20SHAREPOINTSTANDARD_EDU%2C%20EXCHANGE_S_STANDARD%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EPS%20D%3A%5COffice365-Powershell%26gt%3B%20%3CSTRONG%3ESet-MsolUserLicense%20-UserPrincipalName%20%22user%40domain.com%22%20-AddLicenses%20%22tenantID%3ASTANDARDWOFFPACK_FACULTY%22%20-LicenseOptions%20%24MyLicenseOptions%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESet-MsolUserLicense%20%3A%20Unable%20to%20assign%20this%20license%20because%20it%20is%20invalid.%20Use%20the%20Get-MsolAccountSku%20cmdlet%20to%20retrieve%20a%20list%20of%20valid%20licenses.%3CBR%20%2F%3EAt%20line%3A1%20char%3A1%3CBR%20%2F%3E%2B%20Set-MsolUserLicense%20-UserPrincipalName%20%22user%40domain.com%22%20-AddL%20...%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20OperationStopped%3A%20(%3A)%20%5BSet-MsolUserLicense%5D%2C%20MicrosoftOnlineException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20Microsoft.Online.Administration.Automation.InvalidUserLicenseException%2CMicrosoft.Online.Administration.Automation.SetUserLic%3CBR%20%2F%3Eense%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPS%20D%3A%5COffice365-Powershell%26gt%3B%20%3CSTRONG%3EGet-MsolAccountSku%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EAccountSkuId%20ActiveUnits%20WarningUnits%20ConsumedUnits%3CBR%20%2F%3E------------%20-----------%20------------%20-------------%3CBR%20%2F%3EtenantID%3ASTANDARDWOFFPACK_FACULTY%20500720%200%20760%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-34699%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%20Administration%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-119495%22%20slang%3D%22en-US%22%3ERe%3A%20Assign%20selective%20license%20in%20Office%20365%20using%20Powershell%20-%20%22Unable%20to%20assign%20this%20license%20..%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-119495%22%20slang%3D%22en-US%22%3E%3CP%3ERemember%20that%20license%20assignment%20can%20now%20be%20handled%20by%20Azure%20AD%20Groups%20-%20much%20more%20convenient%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Factive-directory-licensing-group-assignment-azure-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Factive-directory-licensing-group-assignment-azure-portal%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-119448%22%20slang%3D%22en-US%22%3ERe%3A%20Assign%20selective%20license%20in%20Office%20365%20using%20Powershell%20-%20%22Unable%20to%20assign%20this%20license%20..%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-119448%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20script%20I%20linked%20to%20is%20convenient%20enough%20for%20me%20%3A)%3C%2Fimg%3E%20It%20might%20take%20some%20adjustments%20to%20better%20fit%20your%20needs%2C%20but%20it's%20definitely%20possible%20to%20bulk%20edit%20licenses%20with%20it%2C%20while%20respecting%20the%20individual%20service%20status.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-119439%22%20slang%3D%22en-US%22%3ERe%3A%20Assign%20selective%20license%20in%20Office%20365%20using%20Powershell%20-%20%22Unable%20to%20assign%20this%20license%20..%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-119439%22%20slang%3D%22en-US%22%3E%3CP%3EThanks.%20So%20do%20you%20agree%20that%20there's%20no%20convenient%20way%20to%20selectively%20enable%2Fdisable%20certain%20services%20so%20that%20we%20can%20treat%20users%20that%20have%20different%20combinations%20of%20services%20in%20bulk%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20imagine%20if%20one%20were%20to%20do%20some%20more%20elaborate%20scripting%20it%20might%20be%20possible.%20Unfortunately%2C%20this%20is%20out%20of%20my%20ability.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-119233%22%20slang%3D%22en-US%22%3ERe%3A%20Assign%20selective%20license%20in%20Office%20365%20using%20Powershell%20-%20%22Unable%20to%20assign%20this%20license%20..%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-119233%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20cmdlets%20overwrite%20the%20service%20settings%2C%20they%20do%20not%20add%2Fremove%20services.%20So%20when%20you%20setup%20the%20%24licenseoptions%20variable%2C%20set%20both%20Yammer%20and%20Office%20to%20disabled.%20This%20script%20shows%20how%20you%20can%20do%20this%20in%20bulk%20for%20all%20users%2C%20respecting%20their%20enabled%2Fdisabled%20services.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-119036%22%20slang%3D%22en-US%22%3ERe%3A%20Assign%20selective%20license%20in%20Office%20365%20using%20Powershell%20-%20%22Unable%20to%20assign%20this%20license%20..%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-119036%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Elet's%20assume%20I%20want%20to%26nbsp%3Bonly%20change%20the%20ProvisioningStatus%20of%20one%20ServicePlan%20and%20a%3C%2FP%3E%3CP%3Euser%20has%20the%20following%20ServicePlans%20set%20(%3CEM%3E(Get-MsolUser%20-UserPrincipalName%20%24user).Licenses.ServiceStatus)%3C%2FEM%3E%3A(%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EServicePlan%20ProvisioningStatus%3CBR%20%2F%3E-----------%20------------------%3CBR%20%2F%3E%3CBR%20%2F%3EYAMMER_ENTERPRISE%20Success%3CBR%20%2F%3EOFFICESUBSCRIPTION%26nbsp%3BDisabled%3CBR%20%2F%3ESHAREPOINTENTERPRISE%20Success%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EI%20want%20to%20set%26nbsp%3B%3CSPAN%3EYAMMER_ENTERPRISE%26nbsp%3Bto%20%22Disabled%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ESo%20I%20tried%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E%24licenseOptions%20%3D%20New-MsolLicenseOptions%20-AccountSkuId%20%22companyname%3AENTERPRISEPACK%22%3CBR%20%2F%3E-DisabledPlans%26nbsp%3B%22%3CSPAN%3EYAMMER_ENTERPRISE%3C%2FSPAN%3E%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3ESet-MsolUserLicense%20-UserPrincipalName%20%24user%20-LicenseOptions%20%24licenseOptions%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20this%20does%20is%20set%26nbsp%3BYAMMER_ENTERPRISE%20to%20%22disabled%22%2C%20as%20expected.%20However%2C%26nbsp%3BOFFICESUBSCRIPTION%20will%20now%20be%20enabled.%20I%20know%20this%20is%20because%20any%20ServicePlan%20not%20specified%20for%26nbsp%3B%3CEM%3E-DisabledPlans%3C%2FEM%3E%20will%20be%20enabled.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20an%20option%20to%20have%20every%20ServicePlan%20remain%20unchanged%20but%20desired%20one%20(here%26nbsp%3BYAMMER_ENTERPRISE)%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20asking%20because%20if%20I%20wanted%20to%20automate%20this%20for%20a%20whole%20tenant%20it'd%20be%20devastating%20if%20all%20ServicePlans%20not%20specified%20for%26nbsp%3B%3CEM%3E-DisabledPlans%3C%2FEM%3E%3CEM%3E%26nbsp%3B%3C%2FEM%3Egot%20enabled%20beacuse%20many%20times%20different%20users%20have%20different%20combinations%20of%20ServicePlans%20enabled%2Fdisabled%20and%20the%20should%20remain%20unchanged.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20help%20in%20advance.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-112718%22%20slang%3D%22en-US%22%3ERe%3A%20Assign%20selective%20license%20in%20Office%20365%20using%20Powershell%20-%20%22Unable%20to%20assign%20this%20license%20..%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-112718%22%20slang%3D%22en-US%22%3E%3CP%3EPerfect%2C%3C%2FP%3E%3CP%3EThis%20script%20helped%20me%20a%20lot%2C%20in%20assigning%20pending%20plans%20to%20users%20already%20licensed.%3C%2FP%3E%3CP%3EThank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-34837%22%20slang%3D%22en-US%22%3ERe%3A%20Assign%20selective%20license%20in%20Office%20365%20using%20Powershell%20-%20%22Unable%20to%20assign%20this%20license%20..%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34837%22%20slang%3D%22en-US%22%3E%3CP%3EGot%20it%20working.%20This%20enables%20all%20licenses%20in%20the%20SKU%20while%20leaving%20previously%20assigned%20licenses%20untouched.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPS%20C%3A%5CUsers%5CIan%26gt%3B%20%3CSPAN%3E%24MyLicenseOptions%20%3D%20New-MsolLicenseOptions%20-AccountSkuId%20%22mytenant%3ASTANDARDWOFFPACK_FACULTY%22%3C%2FSPAN%3E%3CSPAN%3E%20-DisabledPlans%20%24null%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPS%20C%3A%5CUsers%5CIan%26gt%3B%3CSPAN%3E%20PS%20C%3A%5CUsers%5CIan%26gt%3B%20Set-MsolUserLicense%20-UserPrincipalName%20%22user%40domain.com%22%20-LicenseOptions%20%24MyLicenseOptions%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-34791%22%20slang%3D%22en-US%22%3ERe%3A%20Assign%20selective%20license%20in%20Office%20365%20using%20Powershell%20-%20%22Unable%20to%20assign%20this%20license%20..%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34791%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20Vasil%2C%20tried%20that%20by%20removing%20that%20parameter%20and%20it%20actually%20removed%20%3CSTRONG%3Eall%3C%2FSTRONG%3E%20licenses%20from%20the%20user%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESet-MsolUserLicense%20-UserPrincipalName%20%22user%40domain.com%22%20%22tenantID%3ASTANDARDWOFFPACK_FACULTY%22%20-LicenseOptions%20%24MyLicenseOptions%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-34769%22%20slang%3D%22en-US%22%3ERe%3A%20Assign%20selective%20license%20in%20Office%20365%20using%20Powershell%20-%20%22Unable%20to%20assign%20this%20license%20..%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34769%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20the%20user%20already%20has%20the%20same%20SKU%20assigned%2C%20you%20should%20not%20use%20the%20AddLicenses%20parameter%2C%20only%20the%20LicenseOptions%20one.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Regular Contributor

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

9 Replies
Highlighted

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

Highlighted

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

Highlighted

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

Highlighted

Perfect,

This script helped me a lot, in assigning pending plans to users already licensed.

Thank you

Highlighted

Hi,

 

let's assume I want to only change the ProvisioningStatus of one ServicePlan and a

user has the following ServicePlans set ((Get-MsolUser -UserPrincipalName $user).Licenses.ServiceStatus):(

 

ServicePlan ProvisioningStatus
----------- ------------------

YAMMER_ENTERPRISE Success
OFFICESUBSCRIPTION Disabled
SHAREPOINTENTERPRISE Success

I want to set YAMMER_ENTERPRISE to "Disabled"

So I tried:

 

$licenseOptions = New-MsolLicenseOptions -AccountSkuId "companyname:ENTERPRISEPACK"
-DisabledPlans "YAMMER_ENTERPRISE"

 

Set-MsolUserLicense -UserPrincipalName $user -LicenseOptions $licenseOptions

 

What this does is set YAMMER_ENTERPRISE to "disabled", as expected. However, OFFICESUBSCRIPTION will now be enabled. I know this is because any ServicePlan not specified for -DisabledPlans will be enabled.

 

Is there an option to have every ServicePlan remain unchanged but desired one (here YAMMER_ENTERPRISE)?

 

I'm asking because if I wanted to automate this for a whole tenant it'd be devastating if all ServicePlans not specified for -DisabledPlans got enabled beacuse many times different users have different combinations of ServicePlans enabled/disabled and the should remain unchanged.

 

Thanks for your help in advance.

Highlighted

The cmdlets overwrite the service settings, they do not add/remove services. So when you setup the $licenseoptions variable, set both Yammer and Office to disabled. This script shows how you can do this in bulk for all users, respecting their enabled/disabled services.

Thanks. So do you agree that there's no convenient way to selectively enable/disable certain services so that we can treat users that have different combinations of services in bulk?

 

I imagine if one were to do some more elaborate scripting it might be possible. Unfortunately, this is out of my ability.

Highlighted

The script I linked to is convenient enough for me :) It might take some adjustments to better fit your needs, but it's definitely possible to bulk edit licenses with it, while respecting the individual service status.

Highlighted
Related Conversations