Others

Fix Get-Content Positional Parameter Error in SharePoint PowerShell

Camila MilosovichCamila Milosovich Oct 22, 2026 868 views

Question details

The user needs to fix a positional parameter error triggered when combining commands to provision OneDrive sites.

Fix the Get-Content Positional Parameter Error in SharePoint PowerShell
Product
SharePoint Online PowerShell
Device & OS
not provided
Scenario
Provisioning OneDrive accounts using SharePoint Online Management Shell with a list of users.
Observed behavior
A positional parameter error is returned when Get-Content and Request-SPOPersonalSite are executed on the exact same command line.
Before you start

Ensure you are running the SharePoint Online Management Shell as an administrator and that the file path for your user list text file is completely accurate.

Solution 1Recommended

Run Commands Separately Using Variables

Separating the commands into distinct lines prevents parameter conflicts and correctly passes the list of emails to the provisioning command.

PowerShell can misinterpret arguments if multiple cmdlets that manipulate pipeline data are written on a single line without proper pipelining or variable assignment. By storing the contents of your text file into a variable first, you guarantee that Request-SPOPersonalSite receives the correct data type.

1
Create a variable for the user list

Type $users = Get-Content -Path "C:\Users.txt" to read the email addresses from your text file and store them.

2
Execute the provisioning command

Type Request-SPOPersonalSite -UserEmails $users as a separate command to initialize the OneDrive sites.

3
Use Shift+Enter for multiline inputs

If you prefer typing both commands into the PowerShell console before executing them, press Shift+Enter after the first command to drop to a new line without triggering execution.

Run Commands Separately Using Variables
Syntax Formatting: Using properly defined variables makes your PowerShell scripts much easier to read and troubleshoot in the future.
Free Microsoft Office alternative

Looking for a Lighter Way to Manage Documents?

While SharePoint and PowerShell are essential for administrative environment setups, managing your daily documents shouldn't require complex commands. WPS Office provides a lightweight, comprehensive, and entirely free solution for your everyday productivity needs.

Seamlessly edit and save files in native Microsoft Office formats (DOCX, XLSX, PPTX).Easily open and manage documents downloaded from your newly provisioned OneDrive environments.Enjoy a familiar user interface that requires absolutely zero learning curve.Lightweight application footprint that runs efficiently on Windows, Mac, and Linux.
microsoft office alternative - wps office

Frequently Asked Questions

Why does PowerShell throw a positional parameter error?

This error occurs when PowerShell receives input that it cannot automatically map to a specific parameter name. In this context, typing two distinct cmdlets back-to-back without a pipe (|) or line break confuses the shell regarding which arguments belong to which parameter.

Can I use a CSV file instead of a text file for Get-Content?

Yes, but you should use the Import-Csv cmdlet instead of Get-Content. You will then need to specify the exact column property that contains the email addresses before passing them to Request-SPOPersonalSite.

How do I know if the Request-SPOPersonalSite command was successful?

The cmdlet places the provisioning requests into a queue. It does not return an immediate success message. You can verify the site creation by checking the Active sites list in the SharePoint admin center after a few minutes.