none
Bulk E3 to E5 license change RRS feed

  • Question

  • How to bulk change E3 to E5 license using Powershell. I want to change all users who are part of Mumbai city. Kindly help.
    • Moved by Bill_Stewart Wednesday, September 4, 2019 7:46 PM This is not "scripts on demand"
    Monday, April 1, 2019 7:24 AM

All replies


  • Import-Module MSOnline
    $cred = Get-Credential
    Connect-MsolService -Credential $cred
     
    $oldLicense = "contoso:ENTERPRISEPACK"
    $newLicense = "contoso:ENTERPRISEPREMIUM"
     
    $users = Get-MsolUser -MaxResults 5000 | Where-Object { ($_.isLicensed -eq "TRUE" -and $_.city -eq "Mumbai")}
     
    foreach ($user in $users){
        $upn = $user.UserPrincipalName
        foreach ($license in $user.Licenses) {
            if ($license.AccountSkuId -eq $oldLicense) {
                $disabledPlans = @()
                Write-Host("User $upn will go from $oldLicense to $newLicense and will have no options disabled.")
                Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses $newLicense -RemoveLicenses $oldLicense
            }
        }
    }

    But I suggest to manage License using AD Groups.


    If you find my reply helpful, please “Mark as Answer” and “Vote

    Get help on demand  expertise-as-a-service.com



    Monday, April 1, 2019 7:54 AM