SOLVED

How to disable IMAP/POP3 globally but excluding a specific mailbox?

Iron Contributor

Hi,

 

We want to disable IMAP/POP3 to entire organization, but allow a couple mailboxes to have those features. How can we approach it?

 

Please help!

 

Thanks in advance! 

15 Replies

Hi @Grace Yin

There are a few ways you could approach it

1.) You could manually turn them off in the Exchange Admin Centre for each user. You would do this by going to recipients, selecting each mailbox and then turning off these mailbox protocols

2.) You could do this with Powershell, either by writing a script which turns off these protocols for all selected users with the exception of the ones you need, or disable the protocols on all mailboxes via Powershell commands (link below) and then turning the protocols back on for the ones you want, again through Powershell, or by the Exchange Admin console.

https://gcits.com/knowledge-base/disable-pop-imap-mailboxes-office-365/

 

 

There is also a Uservoice to have them disabled by default in the future, as in when creating new mailboxes

 

https://office365.uservoice.com/forums/273493-office-365-admin/suggestions/20454628-disable-imap-and...


Hope that helps and answers your question.

Best, Chris

Hi Chris,

 

Thank you very much for your reply. The link is very helpful. The only thing that I need help is how to exclude a specific mailbox? I am not good at PowerShell, if you can add the command of excluding mailbox like abc@abc.com, that will be great!

 

Your help is appreciated! 

Hi Grace,

If you aren't good at Powershell then rather and try writing a script (unless someone in this forum provides you with one) I would disable the protocols in the Exchange Online admin portal for the selected users or use powershell to disable all users then immediately after enable the protocols on the few mailboxes you need with this article

https://support.microsoft.com/en-in/help/2416434/how-to-enable-or-disable-pop3-imap-mapi-outlook-web...

Hope that helps

Best, Chris

Hi Chris,

 

Your second option can do it, however we will need to disable IMAP/POP for the new created mailboxes manually whenever we creating a new account. We want to automate it. My ideal is to schedule a daily task to disable IMAP/POP for all mailboxes but excepting the specific mailboxes. I just don't know how to add the excluding mailbox command.

 

Thanks,

Hi Grace,

The Powershell command here will disable for all future mailbox created

https://gcits.com/knowledge-base/disable-pop-imap-mailboxes-office-365/

1.) Disable all mailboxes
2.) Enable the ones you want
3.) Disable all future mailboxes

Best, Chris

Hi Chris,

 

Thank you very much! I didn't get it earlier. Yes, this is exact what I want.

 

Just want to confirm what the future mailbox means. Does it mean the new created mailbox after the first script running? Can I schedule the script to run daily so I don't have to manually run it every time after I create an account? Please advise!

 

Many thanks!

Hi @Grace Yin

Well, there is a probably an easier way than that. So you do the following

1.) Disable all mailboxes with the Powershell script provided earlier
2.) Enable the ones you want with the Poweshell script provided earlier

For all new mailboxes
3.) Create new mailbox
4.) Disable IMAP and POP3 on that new mailbox here

https://support.microsoft.com/en-in/help/2416434/how-to-enable-or-disable-pop3-imap-mapi-outlook-web...

After you have done 1 and 2 you don't need to do them again. You just do actions 3 and 4 when you need to create a new mailbox.

Best, Chris

Hi Chris,

 

Do we need to do step 4 manually every time when we create a new account?  

 

Thanks,

Yes, it just a Powershell script to disable the IMAP/POP protocols on the mailbox.

So disable all once
Enable the ones you want once

Then when you create the mailbox and run the Powershell script to disable that mailbox. Should take about 2 minutes to do, That avoids the manual work of logging into the control panel and disabling them manually!

Hope that clarifies and gives you the answer you need.

Best, Chris

Hi Chris,

 

This will do, but I prefer automation. I wonder if it is possible to excluding the specific mailbox in the disable all mailbox script. 

 

Maybe I should post on PowerShell forum.

 

Thank you anyway! 

 

Best,

It's almost certainly possible, as PowerShell is very flexible, however we cannot give you a specific answer without knowing all the details. One way would be to simply "hardcode" the addresses of these mailboxes as an exclusion in the script, so no matter how many times it runs it never toggles the setting on/off. You can also generalize this to using a CSV file which the script reads from.

Hi Vasil,

 

Thank you for your reply. Below is the scrip that I found online and tested and it works. It will disable IMAP/POP for all mailboxes. If I want to exclude mailbox abc@abc.com in this script, can you help me to modify the script?

 

$IMAPMBX = Get-CASMailbox -ResultSize Unlimited | ?{($_.ImapEnabled -eq $true) -or ($_.PopEnabled -eq $true)}

$IMAPCount = $IMAPMBX.count

 

If ($IMAPCount -gt "0") {

 

    ForEach ($I in $IMAPMBX) {

   

        $UPN = $I.PrimarySMTPAddress

        $Alias = $Identity

 

        "--------[IMAP/POP Disable]Start Processing IMAP/POP Disable for Mailbox $UPN--------" | Out-File -Filepath $Logpath2 -Append

       

        try {

   

            $error.Clear()

       

            write-host "Disable IMAP/POP for mailbox $UPN" -ForegroundColor GREEN

            "Disable IMAP/POP for mailbox $UPN" | Out-File -FilePath $LogPath2 -Append

             Set-CASMailbox -Id $UPN -IMAPEnabled $false

             Set-CASMailbox -Id $UPN -POPEnabled $false

 

        }

 

        Catch {

   

            write-host "ERROR - Disabling IMAP/POP for $UPN" -ForeGroundColor RED

            "ERROR - Disabling IMAP/POP for $UPN" | Out-File -FilePath $LogPath2 -Append

            $error | Out-File -FilePath $LogPath2 -Append

                   

        }

   

    }

   

}    

 

Thanks in advance!

best response confirmed by Grace Yin (Iron Contributor)
Solution

I called Microsoft today. There is the script to disable IMAP/POP for all mailboxes expect abc@abc.com.

 

Get-CASMailbox -ResultSize Unlimited | where {$_.Name -ne "abc"} | Set-CASMailbox -PopEnabled $false -ImapEnabled $false

 

Note: abc is the display name of mailbox abc@abc.com. 

is this also including Shared Mailboxes that are licensed?

 

 

fyi, Configuring the CAS Mailbox Plan will help with future mailbox creations. 

https://gcits.com/knowledge-base/disable-pop-imap-mailboxes-office-365/

Disabling IMAP and POP for all future mailboxes

1
Get-CASMailboxPlan -Filter {ImapEnabled -eq "true" -or PopEnabled -eq "true" } | set-CASMailboxPlan -ImapEnabled $false -PopEnabled $false

Disabling IMAP and POP for all existing mailboxes

1
Get-CASMailbox -Filter {ImapEnabled -eq "true" -or PopEnabled -eq "true" } | Select-Object @{n = "Identity"; e = {$_.primarysmtpaddress}} | Set-CASMailbox -ImapEnabled $false -PopEnabled $false
1 best response

Accepted Solutions
best response confirmed by Grace Yin (Iron Contributor)
Solution

I called Microsoft today. There is the script to disable IMAP/POP for all mailboxes expect abc@abc.com.

 

Get-CASMailbox -ResultSize Unlimited | where {$_.Name -ne "abc"} | Set-CASMailbox -PopEnabled $false -ImapEnabled $false

 

Note: abc is the display name of mailbox abc@abc.com. 

View solution in original post