Forum Discussion
msissues2552
Mar 20, 2023Copper Contributor
Disabling mailbox in Exchange Online - VB.NET
Hello I had used a code in the past - to disable AD accounts and mailboxes (VB.NET) for terminated users, that I used for years without a problem. Trying to set it up at my new job, however code doe...
mderooij
Mar 21, 2023MVP
It's been like this for a while. You don't disable mailboxes in Exchange Online, you remove the license (or Exchange plan) to deprovision the mailbox. The cmdlet complains that it cannot figure out what to do: you can only specify archive (to remove any enabled archive) or permanently remove an already soft-deleted mailbox and strip its attributes (ie unlicensed), so it won't get reattached when you reapply licenses within 30 days. Be advised that holds might also prevent you from disabling mailboxes.
- msissues2552Mar 21, 2023Copper Contributor
mderooij thank you. So how do I soft delete mailbox (which command)? Which command removes the license?
- mderooijMar 21, 2023MVPThere is no command in EXO. What you can do is unlicense/remove the EXO plan through Graph, or when using Group-Based Licensing, you can remove the user from the group that provides the plan. Note that deprovisioning is not instant, so you might require a few checks (loop) when waiting for the deprovisioning to take place.
- msissues2552Mar 22, 2023Copper ContributorThank you. That's so odd - used disable mailbox command on O365 mailboxes just in Dec 2022 - through Visual basic code (runspace and powershell). What do people use now for disabling termed accounts automatically? MsGraph API?