Deleted the contents of an Exchange 365 mailbox

Set-ExecutionPolicy RemoteSigned

$LiveCred = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection

Import-PSSession $Session

​Get-MailboxFolderStatistics username@domain.com | Select Identity, ItemsInFolder

​​Search-Mailbox -id username@domain.com -DeleteContent -force

Leave a comment

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

CAPTCHA ImageChange Image