fbpx

How to remove all Office 365 connected accounts in bulk

How to remove all Office 365 connected accounts in bulk

If you’re using connected accounts to assist with an Office 365 migration, you’ll probably want to remove them all once the email downloads have completed. (Also, if you’re not sure why you’d want to use Office 365 connected accounts during certain Office 365 migrations, check out our guide here.)

How to remove all connected accounts from an Office 365 tenant via PowerShell

  1. Connect to Exchange Online via Powershell. Follow our quick guide here for instructions on how to do this.
  2. Run $mailboxes = Get-Mailbox
    $mailboxes = Get-Mailbox
  3. To see a list of all current connected accounts run either of the following cmdlets. This cmdlet will get all current POP connected accounts:
    foreach ($mailbox in $mailboxes) {Get-PopSubscription -Mailbox $mailbox.primarysmtpaddress | ft Emailaddress,subscriptiontype}

    This cmdlet will get all current IMAP connected accounts:

    foreach ($mailbox in $mailboxes) {Get-ImapSubscription -Mailbox $mailbox.primarysmtpaddress | ft Emailaddress,subscriptiontype}
  4. To remove the accounts, run either of the following – depending on whether you’re removing POP or IMAP accounts.
    POP cmdlet:

    foreach ($mailbox in $mailboxes) {Get-PopSubscription -Mailbox $mailbox.primarysmtpaddress | Remove-Subscription -Confirm:$false}

    IMAP cmdlet:

    foreach ($mailbox in $mailboxes) {Get-ImapSubscription -Mailbox $mailbox.primarysmtpaddress | Remove-Subscription -Confirm:$false}
  5. To confirm that it’s worked, run the code from step 3 again. You should see no connected accounts.Office 365 Connected Accounts Removal

 

 

Was this article helpful?

Related Articles

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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