Remove allocated O365 licenses for specified user using PS Script

Copper Contributor

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.

2 Replies
And what's the error that you receive?

Any update ?