Forum Discussion
How to disable IMAP/POP3 globally but excluding a specific mailbox?
- Jan 18, 2019
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.
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!
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.
- MrOCanadaJul 15, 2019Copper Contributor
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
1Get-CASMailboxPlan -Filter {ImapEnabled -eq "true" -or PopEnabled -eq "true" } | set-CASMailboxPlan -ImapEnabled $false -PopEnabled $falseDisabling IMAP and POP for all existing mailboxes
1Get-CASMailbox -Filter {ImapEnabled -eq "true" -or PopEnabled -eq "true" } | Select-Object @{n = "Identity"; e = {$_.primarysmtpaddress}} | Set-CASMailbox -ImapEnabled $false -PopEnabled $false - Mario PastoraMar 29, 2019Brass Contributoris this also including Shared Mailboxes that are licensed?