Swap Office 365 Licences

Swap Office 365 Licences

I needed to remove some expired Office 365 licences that were expired to the point where I couldn’t do it via the admin interface so I wrote a PowerShell script to automate swapping the Office 365 licences.

You will want to run Get-MsolAccountSku this will list out the various SKUs your account has. something like this

tenant:VISIOCLIENT
tenant:PROJECTCLIENT
tenant:EXCHANGESTANDARD
tenant:O365_BUSINESS_PREMIUM
tenant:OFFICESUBSCRIPTION
tenant:PROJECTPROFESSIONAL

Just change the values in the script below to match what product you want to remove and replace it with and then run it.

$remove = "tenant:EXCHANGESTANDARD"
$add = "tenant:O365_BUSINESS_PREMIUM"

$swap = get-MSOLUser -All | where {$_.isLicensed -eq "TRUE" -and $_.Licenses.AccountSKUID -eq "$remove"}

Foreach ($User in $swap) {
Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -RemoveLicenses "$remove" -AddLicenses $add
}

That is basically it. It will just run and swap the licences.

theDXT
Posted on:
Post author

Leave a comment

Your email address will not be published. Required fields are marked *