MSOL - Change AzureAD License

This can be modified to just add or remove license

This script currently Adds the M365 E5 License and removes O365 E5. After which will display the user, license and any reconciliation needed.

Connect-MsolService

Get-MsolAccountSku

$CSV = Import-CSV "C:\Temp\User.csv"

$AddLicense = "DEVLAB:SPE_E5"

$RemoveLicense = "DEVLAB:ENTERPRISEPREMIUM"

ForEach ($item in $CSV) { 
  $User = $($item.UserPrincipalName)
  Set-MsolUserLicense -UserPrincipalName $User -AddLicenses "$AddLicense" -RemoveLicenses "$RemoveLicense"
  Get-MsolUser -UserPrincipalName $User | Format-Table UserPrincipalName,Licenses,LicenseReconciliationNeededOnly -AutoSize
}

Last updated

Was this helpful?