
Just a note on this I was applying the licence to existing users who where already setup with a usage location so if this is not set the script will error out. The only part that needs to be updated is the $csv variable to point to the correct folder where the csv files will be kept. The add script is the same only I added a check to confirm if the user requires the licence. Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -RemoveLicenses $accountSKU.AccountSkuId Write-Host "Removing $($accountSKU.AccountSkuId) licence from $($user.UserPrincipalName)" -ForegroundColor Yellow $accountSKU = Get-MsolAccountSku | Select-Object AccountSkuId | Out-GridView -PassThru $csv = Get-ChildItem -Path C:\temp\Office365Licence\Remove\ -File | Out-GridView -PassThru Once the two items are selected the script will then run

The second is to select the SKU to be removed To make things easier and more repeatable in case I need to remove or add other licence I am using Out-GridView -PassThru to select the CSV file and also the licence SKU.įirst Out-GridView is for the Csv file with UserPrincipalName (UPN) Get-MsolAccountSku | Select-Object AccountSkuId Import-Module MSonline and then Connect-MsolService

I thought I would do a quick post on how I moved the licences.Īs always any scripts should be tested on a subset of users before running on larger groups to test that they work as expected.įor this script we need the Office365 PowerShell module installed.įirst step is to get the AccountSKU to do this run

I recently had a to move around a few thousand EMS licences to enable MFA for Office 365 and Azure, I decided to do two quick scripts to remove and add back the licences to the required users.
