Thursday, 21 June 2012

Disable POP and IMAP in Office 365

To disable POP and IMAP for all users in Office 365, follow these steps:

 1. Connect to Exchange Online:
$Credential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "" -Credential $Credential -Authentication Basic -AllowRedirection
$ImportResults = Import-PSSession $Session

2. Read all user mailboxes and disable POP and IMAP:
$Mailboxes = Get-Mailbox -ResultSize Unlimited
ForEach ($Mailbox in $Mailboxes) {$Mailbox | Set-CASMailbox -PopEnabled $False -ImapEnabled $False }

3. close your session to Exchange Online:
Remove-PSSession $Session