Exchange Connection Problems

Fix PowerShell MoveItems Positional Parameter Error in Microsoft 365

John WilsonJohn Wilson Nov 3, 2026 868 views

Question details

The user needs to resolve a positional-parameter error encountered when using a PowerShell script to move Microsoft 365 emails into an archive or between folders.

How to Fix PowerShell MoveItems Error When Moving Microsoft 365 Emails
Product
Microsoft 365 Exchange Online
Device & OS
not provided
Scenario
Attempting to programmatically move emails between mail folders or into a web archive using the MoveItems PowerShell command.
Observed behavior
PowerShell throws an error stating 'A positional parameter cannot be found that accepts argument .\moveitems', preventing the email move operation from executing.
Before you start

Ensure you are connected to Exchange Online PowerShell with an account that has the required Exchange Administrator permissions and the Mailbox Import Export role assigned.

Solution 1Recommended

Correct the Script Invocation and Parameter Syntax

Fixing the syntax of the PowerShell command ensures that all arguments are correctly passed to their corresponding parameters, resolving the positional error.

The error 'A positional parameter cannot be found' typically occurs when PowerShell misinterprets a script path or argument. This happens if you omit named parameters, use spaces incorrectly, or fail to enclose string values in quotation marks.

1
Verify script path execution

If you are executing a custom script named 'moveitems.ps1', ensure you invoke it using the call operator and proper path formatting, such as: & ".\moveitems.ps1".

2
Use explicit named parameters

Instead of passing values based on their position, explicitly declare the parameter names. For example: .\moveitems.ps1 -Mailbox "user@domain.com" -TargetFolder "Archive".

3
Enclose strings in quotes

Wrap any folder names or file paths containing spaces in double quotation marks to prevent PowerShell from treating the second word as a separate positional argument.

4
Test with a single message

Add a constraint to your command or script to test moving just one email message first. This validates your syntax and folder identities without affecting the entire mailbox.

Correct the Script Invocation and Parameter Syntax
Syntax check complete: Always utilize the PowerShell ISE or Visual Studio Code with the PowerShell extension to highlight syntax errors before executing Exchange commands.
Free Microsoft Office alternative

Simplify Your Daily Office Work with WPS Office

While managing Microsoft 365 Exchange environments requires complex PowerShell scripts and administrative troubleshooting, your daily document processing shouldn't be difficult. WPS Office offers a completely free, highly compatible alternative to Microsoft Office, allowing you to create, edit, and manage documents, spreadsheets, and presentations without the overhead.

  1. 1. Download the installer: Visit the official WPS Office website and download the free installation package for your operating system.
  2. 2. Install WPS Office: Run the lightweight installer and follow the on-screen prompts to complete the setup in minutes.
  3. 3. Open your files: Launch WPS Office and directly open your existing docx, xlsx, or pptx files without any formatting loss.
Seamless format compatibility with Microsoft Word, Excel, and PowerPoint files.Lightweight architecture ensuring fast launch times even on older devices.Familiar user interface that requires zero learning curve to master.Powerful built-in PDF toolkit for converting, editing, and signing documents.
microsoft office alternative - wps office

Frequently Asked Questions

Why does PowerShell throw a 'positional parameter cannot be found' error?

This error occurs when PowerShell encounters an argument that it cannot map to a specific parameter. This is commonly caused by missing quotation marks around strings with spaces, omitting parameter names (e.g., typing a value without '-Mailbox'), or having a typo in the script execution path.

Can I move Microsoft 365 emails to an archive without PowerShell?

Yes. Administrators can configure Retention Policies and Archive Mailboxes in the Microsoft Purview compliance portal. End-users can also manually drag and drop emails into their Online Archive folder using Outlook on the web or the Outlook desktop client.

What permissions are required to move mailbox items via PowerShell?

To programmatically move messages or manage mailbox folders via Exchange Online PowerShell, the administrative account typically requires the 'Mailbox Import Export' role, which is not assigned to standard administrators by default and must be explicitly granted.