Forum Discussion

Rohitban's avatar
Rohitban
Copper Contributor
Nov 22, 2022

Remove allocated O365 licenses for specified user using PS Script

I am getting error while running below PS commands after successful authentication. 

 

$Licenses = Get-MgUserLicenseDetail -UserId $Name

 

Get-MgUserLicenseDetail -UserId $Name | foreach {Set-MgUserLicense -UserId $Name -AddLicenses @() -RemoveLicenses @($Licenses.SkuId)}

 

Note : $Name is provided as argument.

Resources