- Office 365
- Deprovisioning
- Okta Classic Engine
NOTE: Okta strongly recommends reaching out to Microsoft before running any of the PowerShell commands in this article.
Removing the Office365 license from a single user is a simple way to stop this behavior. However, this can be tricky when deactivating bulk users.
-
This PowerShell command will provide a list of all users who have an SMTP forwarding address configured. This helps determine which accounts to prioritize when manually removing licenses from Office365.
Get-Mailbox | Where {($.ForwardingSMTPAddress -ne $null) -or ($.ForwardingAddress -ne $null)} | Select Name, ForwardingSMTPAddress, ForwardingAddress, DeliverToMailboxAndForward
NOTE: This command requires the Exchange Online module to be loaded in PowerShell, which is detailed here.
-
The following PowerShell command will find all Office365 designated as “Blocked” and then remove licenses from each of them:
$Blocked = Get-MsolUser -All | Where {$.Blockcredential -like "True" }; $Blocked | foreach {Set-MsolUserLicense -UserPrincipalName $.UserPrincipalName -RemoveLicenses "(AccountSkuId)”}
AccountSkuId refers to the specific license that should be removed and can be found by runningget- msolaccountsku. This will list the AccountSku’s for all licenses utilized in the tenant. In some cases, multiple instances of the above command must be run to ensure all types of licenses are removed from Blocked users.
