PowerShell for Microsoft 365 is a powerful management tool that complements the Microsoft 365 admin center. For example, you can use PowerShell automation to easily manage multiple user accounts and licenses and to create reports
Archiving in Office 365 (also called In-Place Archiving) provides users with additional mailbox storage space. After you turn on archive mailboxes, users can access and store messages in their archive mailboxes by using Microsoft Outlook and Outlook on the web.
Here we are start email archiving in office 365 via powershell.
Connect to office 365 with powershell
open a powershell session and store your credentials in a variable,
$Cred = Get-Credential
Enter your Office 365 Credentials when prompted
Create a new PowerShell session from the Office 365 Server,
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection
Import the session:
and choose Y.
Run the following command to enable the archive mailbox for a single user.
Enable-Mailbox -Identity <username> -Archive
When you enable Exchange Online Archiving for a user on Office 365, it can take 24 hours or more for the Managed Folder Assistant to start it’s first run and begin archiving email out of the primary mailbox.
If you want this process to start immediately, connect to Office 365 with PowerShell and tell the Managed Folder Assistant to start running.
Start-ManagedFolderAssistant -Identity [email protected]
Then wait 5 minutes or so for it to begin running and check the progress via logging in to OWA and looking at either the contents of the In-Place Archive mailbox in the left-hand sidebar or via the Exchange Admin Centre > Mailboxes > Recipients > In-Place Archive > View details