Enable “Mailbox Import Export” role
- Connect to Office 365 Portal
- Select Admin -> Exchange
- Click on Permissions
- Double-click on Organization Management
- Under Roles, click on the plus sign (+)
- Add the Mailbox Import/Export role
- Ensure your account is a member of the Organization Management
- Go to Start>PowerShell right-click on it and run as Administrator
- Enter the following commands to connect PowerShell to Exchange Online
- Set-ExecutionPolicy RemoteSigned
- $UserCredential = Get-Credential
- $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
- Import-PSSession $Session
- Search-mailbox -identity USER@EXAMPLE.COMĀ – -DeleteContent -force