Remove services from O365 license: PowerShell

Iron Contributor

Hi Community,

 

Sometimes we need to remove certain services from a license assigned to the users in M365.

There're many ways to do it, ( also the Admin Center ), but today we'll see how to list and exclude the desired services using PowerShell.

 

First of all, we need to connect to the cloud:

 

Connect-MsolService

 

And list our available licenses:

 

Get-MsolAccountSku | Select AccountSkuId | Sort AccountSkuId

 

The output should look something like this:

 

FcoManigrasso_0-1679926771871.png

 

Then we need to list the services included in our desired license:

 

(Get-MsolAccountSku | where {$_.AccountSkuId -eq "Company:DEVELOPERPACK_E5"}).ServiceStatus

 

The output looks like this:

 

FcoManigrasso_1-1679926983486.png

 

Finally, we only need to use the "New-MsolLicenseOptions" cmdlt in order to disable the service/s. We can run it for the license itself and apply to the whole Company or use a variable to assign that license with the disabled service to specific users:

 

$LO = New-MsolLicenseOptions -AccountSkuId "Company:DEVELOPERPACK_E5" -DisabledPlans "POWERAPPS_O365_P3"
Set-MsolUserLicense -UserPrincipalName email address removed for privacy reasons -LicenseOptions $LO

 

 

1 Reply
MSOL and AzureAD Modules should not be used anymore. Migrate to Microsoft Graph

https://blog.icewolf.ch/archive/2021/11/29/hinzufugen-und-entfernen-von-m365-lizenzen-mit-microsoft-...

#Lizenz vom Benutzer anzeigen
Get-MgUserLicenseDetail -UserId email address removed for privacy reasons

#Lizenz entfernen
Set-MgUserLicense -UserId email address removed for privacy reasons -AddLicenses @() -RemoveLicenses @('e43b5b99-8dfb-405f-9987-dc307f34bcbd') #PhoneSystem

Set-MgUserLicense -UserId email address removed for privacy reasons -AddLicenses @{SkuId = 'e43b5b99-8dfb-405f-9987-dc307f34bcbd'} -RemoveLicenses @() #PhoneSystem