SOLVED

Unable to -RemoveLicenses

%3CLINGO-SUB%20id%3D%22lingo-sub-1131841%22%20slang%3D%22en-US%22%3EUnable%20to%20-RemoveLicenses%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1131841%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20appears%20I%20am%20only%20able%20to%20remove%20licenses%20via%20Powershell%20that%20are%20not%20Assigned%20to%20Users%2FGroups%20or%20Inherited%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3ESet-MsolUserLicense%20-UserPrincipalName%20%22user%40contoso.com%22%20-RemoveLicenses%3C%2FEM%3E%20%3CEM%3E%22contoso%3ASTANDARDPACK%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B-%20I%20receive%20%3CSTRONG%3E%22Set-MsolUserLicense%20%3A%20Unknown%20error%20occurred.%22%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20when%20I%20remove%20something%20that%20does%20not%20have%20any%20Licensed%20Users%20or%20Groups%20Assigned%20in%20AAD%2C%20It%20works.%20Is%20this%20by%20design%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3ESet-MsolUserLicense%20-UserPrincipalName%20%22user%40contoso.com%22%20-RemoveLicenses%20%22contoso%3APOWERAPPS_VIRAL%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EChad%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1131841%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1136409%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20-RemoveLicenses%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1136409%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F534903%22%20target%3D%22_blank%22%3E%40cbuser935%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3BJust%20to%20check%20%3F%20Is%20your%20license%20still%20valid%20or%20has%20been%20cancelled%3F%3C%2FP%3E%3CP%3ECheck%20the%20below%20information%20if%20it's%20true%20for%20your%20case%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20966px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F167817i63934F9CDF00AF23%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22license.PNG%22%20title%3D%22license.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1136906%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20-RemoveLicenses%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1136906%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F534903%22%20target%3D%22_blank%22%3E%40cbuser935%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%2C%20it's%20by%20design.%20If%20you%20assign%20license%20dynamically%20using%20Groups%20in%20AAD%2C%20you%20can%20not%20remove%20them%20with%20set-msoluser%20but%20you%20need%20to%20remove%20the%20user%20from%20the%20groups.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20hope%20it%20helps.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1137144%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20-RemoveLicenses%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1137144%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F526891%22%20target%3D%22_blank%22%3E%40alextt%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20confirming%20this!!!%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

 

It appears I am only able to remove licenses via Powershell that are not Assigned to Users/Groups or Inherited?

 

Set-MsolUserLicense -UserPrincipalName "user@contoso.com" -RemoveLicenses "contoso:STANDARDPACK"

 - I receive "Set-MsolUserLicense : Unknown error occurred."

 

 

However, when I remove something that does not have any Licensed Users or Groups Assigned in AAD, It works. Is this by design?

 

Set-MsolUserLicense -UserPrincipalName "user@contoso.com" -RemoveLicenses "contoso:POWERAPPS_VIRAL"

 

Chad

 

 

3 Replies

@cbuser935 

 Just to check ? Is your license still valid or has been cancelled?

Check the below information if it's true for your case 

license.PNG

best response confirmed by cbuser935 (New Contributor)
Solution

@cbuser935 

 

Yes, it's by design. If you assign license dynamically using Groups in AAD, you can not remove them with set-msoluser but you need to remove the user from the groups.

 

I hope it helps. 

 

@alextt 

Thank you for confirming this!!!