Fix Get-Content Positional Parameter Error in SharePoint PowerShell
Question details
The user needs to fix a positional parameter error triggered when combining commands to provision OneDrive sites.

- 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.
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.
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.
Type $users = Get-Content -Path "C:\Users.txt" to read the email addresses from your text file and store them.
Type Request-SPOPersonalSite -UserEmails $users as a separate command to initialize the OneDrive sites.
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.

Assign Email Directly for a Single User
If you are only provisioning a OneDrive site for one user, you can bypass the Get-Content command entirely by declaring the email directly in the script.
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.

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.




