May 30 2017 06:51 AM - last edited on Nov 09 2023 11:09 AM by
I want to run a powershell script to disable the Teamoption in all users licenses.
$license = "contoso: ENTERPRISEPACK_FACULTY"
$LicenseOptions = New-MsolLicenseOptions -AccountSkuId $license -DisabledPlans TEAMS1
Set-MsolUserLicense -UserPrincipalName "testcase@contoso.com" -AddLicenses $license -LicenseOptions $LicenseOptions
Then I get an error:
Set-MsolUserLicense : Unable to assign this license because it is invalid.
What am I doing wrong?
May 30 2017 07:32 AM
May 30 2017 07:40 AM
May 30 2017 11:25 PM
May 31 2017 01:54 AM - edited May 31 2017 02:29 AM
Did you try something like the following already?
$LicenseOptions = New-MsolLicenseOptions -AccountSkuId $license -DisabledPlans TEAMS1
$AllLicensed = Get-MsolUser -All | where {$_.isLicensed -eq $true};
$AllLicensed | foreach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -LicenseOptions $LicenseOptions }
Where "tenant" is the name of your tenant.
May 31 2017 01:55 AM
Sorry, the objectid was missing, please check the below updated script.
$LicenseOptions = New-MsolLicenseOptions -AccountSkuId $license -DisabledPlans TEAMS1
$AllLicensed = Get-MsolUser -All | where {$_.isLicensed -eq $true};$AllLicensed | foreach {Set-MsolUserLicense -ObjectId $_.ObjectId -LicenseOptions $LicenseOptions }
Jun 01 2017 12:58 AM
Same result:
Set-MsolUserLicense : Unable to assign this license because the license options
are invalid.
At line:1 char:25
Jun 01 2017 01:04 AM
Jun 01 2017 05:01 AM
SolutionJun 01 2017 06:19 AM
Instead of using PowerShell, you may want to start using Group Based Licensing in Azure AD, see https://docs.microsoft.com/en-us/azure/active-directory/active-directory-licensing-group-assignment-...
Jun 02 2017 12:03 AM
Thanx, this tool is great and solved my problem.
Jun 21 2017 01:43 PM
This tool is amazing. Microsoft should take note. @Lana OBrien
Jun 01 2017 05:01 AM
Solution