Jan 16 2019 03:17 PM
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!
Jan 16 2019 03:31 PM - edited Jan 16 2019 03:36 PM
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
Hope that helps and answers your question.
Best, Chris
Jan 16 2019 03:42 PM
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!
Jan 16 2019 03:59 PM
Jan 16 2019 04:24 PM
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,
Jan 16 2019 04:34 PM
Jan 16 2019 04:48 PM
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!
Jan 16 2019 04:54 PM
Jan 16 2019 04:57 PM
Hi Chris,
Do we need to do step 4 manually every time when we create a new account?
Thanks,
Jan 16 2019 05:01 PM
Jan 16 2019 05:05 PM
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,
Jan 17 2019 07:27 AM
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.
Jan 17 2019 09:39 AM
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!
Jan 17 2019 04:44 PM
SolutionI 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.
Mar 29 2019 07:27 AM
Jul 15 2019 10:21 AM
fyi, Configuring the CAS Mailbox Plan will help with future mailbox creations.
https://gcits.com/knowledge-base/disable-pop-imap-mailboxes-office-365/
1 | Get-CASMailboxPlan -Filter {ImapEnabled -eq "true" -or PopEnabled -eq "true" } | set-CASMailboxPlan -ImapEnabled $false -PopEnabled $false |
1 | Get-CASMailbox -Filter {ImapEnabled -eq "true" -or PopEnabled -eq "true" } | Select-Object @{n = "Identity"; e = {$_.primarysmtpaddress}} | Set-CASMailbox -ImapEnabled $false -PopEnabled $false |
Jan 17 2019 04:44 PM
SolutionI 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.