Forum Discussion

Harry Dubois's avatar
Harry Dubois
Copper Contributor
May 30, 2017
Solved

Powershell to disable Teams for all users

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?

12 Replies

  • To disable TEAMS for all users, you can try the below script

    $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $license -DisabledPlans TEAMS1

    $AllLicensed = Get-MsolUser -All | where {$_.isLicensed -eq $true}; $AllLicensed | foreach {Set-MsolUserLicense -LicenseOptions $LicenseOptions }
    • Harry Dubois's avatar
      Harry Dubois
      Copper Contributor
      The script for all users is asking me an input:

      cmdlet Set-MsolUserLicense at command pipeline position 1
      Supply values for the following parameters:
      ObjectId:

      What is wrong here?

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

Resources