How to Create OneDrive Folders from a CSV Using PowerShell
Question details
An administrator needs to automatically provision OneDrive for Business sites for new users and create a predefined folder structure inside their Documents library using a CSV file.

- Product
- OneDrive for Business
- Device & OS
- not provided
- Scenario
- Onboarding new Microsoft 365 users and preparing their default cloud storage environments with standardized directories.
- Observed behavior
- The administrator seeks an automated script-based approach to bulk create folders based on CSV data rather than manually setting up each user's OneDrive workspace.
Ensure you have SharePoint Administrator privileges in your Microsoft 365 tenant and have installed the latest SharePoint Online Management Shell and PnP PowerShell modules.
Use a PowerShell Script to Provision and Create Folders
Execute a customized PowerShell script that reads user details from a CSV, provisions the OneDrive site if it doesn't exist, and creates the required folder structure.
Automating OneDrive site provisioning and folder creation requires interacting with SharePoint Online (SPO) services. The process involves looping through a CSV file, requesting site creation for each user, and then pushing folders to the user's personal document library.
Because provisioning a new OneDrive site is not instantaneous, your script will need to account for a short delay or verification loop before attempting to add folders using PnP cmdlets.
Create a CSV file containing columns for the user's User Principal Name (UPN) and the target folder paths you want to generate. Save this file to a known local directory.
Open PowerShell as an administrator. Use the Connect-SPOService cmdlet to authenticate to your tenant's SharePoint admin center URL using your administrator credentials.
In your script loop, use the Request-SPOPersonalSite cmdlet for each UPN in the CSV. This command triggers the creation of the user's OneDrive site if it has not been provisioned yet.
Once the site is active, authenticate to the specific user's OneDrive URL using Connect-PnPOnline. Utilize the Add-PnPFolder cmdlet to programmatically create the folders defined in your CSV within the 'Documents' library.

Manage and Edit Your Cloud Documents Seamlessly with WPS Office
While provisioning OneDrive infrastructure requires Microsoft 365 admin tools, your users need a reliable and fast way to work with the documents stored inside those new folders. WPS Office is a powerful, lightweight alternative to Microsoft Office that easily handles daily document tasks.
- 1. Download the Installer: Visit the official WPS Office website and download the free installer for your operating system.
- 2. Install and Launch: Run the installation file. Once completed, open WPS Office to access Writer, Spreadsheets, and Presentation.
- 3. Open Cloud Documents: Navigate to the Open menu to browse and edit files stored directly in your local synced OneDrive folders.

Frequently Asked Questions
Can I create folders for users who do not have a Microsoft 365 license yet?
No. Users must be assigned a Microsoft 365 license that includes OneDrive or SharePoint Online before their personal site can be successfully provisioned via PowerShell.
How long does it take for Request-SPOPersonalSite to provision the OneDrive?
Provisioning typically takes a few minutes but can take longer depending on backend server loads. It is highly recommended to add a delay or a verification loop in your PowerShell script before running folder creation commands.
Do I need to be a Global Administrator to run these commands?
You need to be at least a SharePoint Administrator in your Microsoft 365 tenant to provision OneDrive sites and manage personal site collections programmatically.
Can this method create nested subfolders?
Yes. By specifying the full relative path in your CSV or script (for example, 'ParentFolder/SubFolder'), commands like Add-PnPFolder can create nested directory structures inside the user's Documents library.




