Connecting to Office 365 and enabling mailbox archive

How to enable archiving for Office 365 mailbox

STEP 1. Connect to 365

$UserCredential = Get-Credential

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

Import-PSSession $Session

 

STEP 2. Enable archiving for mailbox example Kim

Enable-Mailbox "Kim" -Archive -ArchiveName "365 Online Archive"

 

STEP 2.1 Enable archiving for the entire organization

Get-Mailbox -Filter {ArchiveStatus -Eq "None" -AND RecipientTypeDetails -eq "UserMailbox"} | Enable-Mailbox -Archive

 

STEP 2.2 Change default folder name “In-Place Archiving” to something else for all users

Example 1)

$users = Get-Mailbox -ResultSize unlimited -Filter { ArchiveStatus -Eq "None" -AND RecipientTypeDetails -eq 'UserMailbox'}

ForEach ($a in $users) {$a.ArchiveName.Add("365 Online Archive- $a")}

$users | %{Enable-Mailbox $_.Identity -Archive -ArchiveName $_.ArchiveName}

Example 2)

$users = Get-Mailbox -ResultSize unlimited -Filter {PrimarySmtpAddress -Eq "xxx@xxx.com.sg";}

ForEach ($a in $users) {$a.ArchiveName.Add("365 Online Archive- $a")}

#If you wish to see the content before executing
foreach ($a in $users) {$a | fl Name, *Archive*}

$users | %{Enable-Mailbox $_.Identity -Archive -ArchiveName $_.ArchiveName}

 

STEP 3. Check if archiving is working

Get-Mailbox <Name> | FL Name,*Archive*

 

STEP 3.1 Disable archiving

Disable-Mailbox -Identity "Kim" -Archive

 

Once completed end the session

Remove-PSSession $Session

Leave a Reply

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

Scroll to top