How to Enable Online Archive for All users With PowerShell

The In-Place Archive that you get with Exchange Online, provides your users with additional storage space. With PowerShell, we can enable the archive mailboxes quickly for all users.

Load the Exchange Online PowerShell module

If the module is already installed, you can typically skip this step and run Connect-ExchangeOnline without manually loading the module first.

After you’ve installed the module, open a PowerShell window and load the module by running the following command:

Import-Module ExchangeOnlineManagement

Connect and authenticate

Connect commands will likely fail if the profile path of the account that you used to connect contains special PowerShell characters. The workaround is to connect using a different account that doesn’t have special characters in the profile path.

The command that you need to run uses the following syntax:

Connect-ExchangeOnline -UserPrincipalName <UPN> [-UseRPSSession] [-ExchangeEnvironmentName <Value>] [-ShowBanner:$false] [-DelegatedOrganization <String>] [-PSSessionOption $ProxyOptions]

Get a list of users without In-place Archive

To check if there are users without the archive mailbox, you can run the following cmdlet

Get-Mailbox -Filter {ArchiveGuid -Eq “00000000-0000-0000-0000-000000000000” -AND RecipientTypeDetails -Eq “UserMailbox”}

Enabling the archive

You can enable the archive for a single user with the following cmdlet

Enable-Mailbox -Identity “<user>” -Archive

Or for all users at once with

Get-Mailbox -Filter {ArchiveGuid -Eq “00000000-0000-0000-0000-000000000000” -AND RecipientTypeDetails -Eq “UserMailbox”} | Enable-Mailbox -Archive

Ref: Connect to Exchange Online PowerShell | Microsoft Learn

https://learn.microsoft.com/en-us/microsoft-365/compliance/enable-archive-mailboxes?view=o365-worldwide

https://learn.microsoft.com/en-us/exchange/policy-and-compliance/in-place-archiving/manage-archives?view=exchserver-2019