Fix PowerShell MoveItems Positional Parameter Error in Microsoft 365
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.

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

Use Microsoft Graph or Exchange Online Archiving
If custom MoveItems scripts fail, utilize built-in Exchange Online retention policies or Microsoft Graph APIs for a more reliable archiving method.
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. Download the installer: Visit the official WPS Office website and download the free installation package for your operating system.
- 2. Install WPS Office: Run the lightweight installer and follow the on-screen prompts to complete the setup in minutes.
- 3. Open your files: Launch WPS Office and directly open your existing docx, xlsx, or pptx files without any formatting loss.

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.




