Connect to Exchange Online PowerShell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force;
Install-PackageProvider -Name NuGet -Force;
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted;
Install-Module -Name ExchangeOnlineManagement;
Import-Module ExchangeOnlineManagement;
Connect-ExchangeOnline;
Enable archive mailboxes
Run the following command to enable the archive mailbox for a single user.
Enable-Mailbox -Identity -Archive
Run the following command to enable the archive mailbox for all users in your organization (whose archive mailbox is currently not enabled).
Get-Mailbox -Filter {ArchiveGuid -Eq "00000000-0000-0000-0000-000000000000" -AND RecipientTypeDetails -Eq "UserMailbox"} | Enable-Mailbox -Archive
Disable archive mailboxes
Run the following command to disable the archive mailbox for a single user.
Disable-Mailbox -Identity -Archive
Run the following command to disable the archive mailbox for all users in your organization (whose archive mailbox is currently enabled).
Get-Mailbox -Filter {ArchiveGuid -Ne "00000000-0000-0000-0000-000000000000" -AND RecipientTypeDetails -Eq "UserMailbox"} | Disable-Mailbox -Archive
5/5 - (1 vote)