macbook pro

Today, I will explain how to disable a particular office 365 license for single or multiple users. We will disable Microsoft teams but you can disable license as per your requirement.

First connect to Azure AD Powershell and run Connect-MsolService, It will prompt for Azure Administrator credentials.


In this script we are pulling list of users from usr.txt placed on desktop and exracting report on Skype of Business (MCOSTANDARD) and Teams (TEAMS1) status.

Save this file as a licensestatus.ps1 on your desktop.

$ALLUSERS= gc C:\Users\sourabh.jha\Desktop\teams.txt | % {Get-MSOLUser -UserPrincipalName $_}

foreach($msolUser in $ALLUSERS)

  $UserInfo = Get-MSOLUser -UserPrincipalName $msolUser.UserPrincipalName
  foreach($license in $msolUser.Licenses)
   if ($license.servicestatus|where {$_.serviceplan.servicename -like "MCOSTANDARD"})
      $MCOSTANDARD=$license.servicestatus|where {$_.serviceplan.servicename -like "MCOSTANDARD"}
   if ($license.servicestatus|where {$_.serviceplan.servicename -like "TEAMS1"})
      $TEAMS1=$license.servicestatus|where {$_.serviceplan.servicename -like "TEAMS1"}

   $LICENSEOBJECT += New-Object PsObject -Property @{

   write "Processing $($UserInfo.DisplayName) $COUNTER \ $ALLUSERSCOUNT"

#This line creates a CSV for your personal use
$LICENSEOBJECT | SELECT DisplayName,UserPrincipalName,TEAMS1,M* | export-csv License.csv -NoTypeInformation

#This line outputs the data into Out-Gridview
$LICENSEOBJECT | SELECT DisplayName,UserPrincipalName,TEAMS1,M* | Out-GridView

Now, We have list of people who need changes, we will first find out the name of SKU which contains MSTeams. In this case it is learn:ENTERPRISEPACK

Refer for more info on SKU


Figure out the name of plan you want to disable, like for teams then name is ‘TEAMS1’

 $x = New-MsolLicenseOptions -AccountSkuId $acctSKU -DisabledPlans "TEAMS1"

Test disabling for one user for One user :

 Get-MsolUser -UserPrincipalName | Set-MsolUserLicense -LicenseOptions $x 

Copy list of users to a input file, in this case i have mentioned the email address in teams.txt, Mention user detail in each line.

Now you can run this command.

 gc .\teams.txt | % {Get-MsolUser -UserPrincipalName $_ | Set-MsolUserLicense -LicenseOptions $x} 

You can run above licensestatus.ps1 again to verify that licenses were disabled.

Thank you for reading.