Skip to content
Rishan Solutions
Rishan Solutions
  • PowerApps
  • SharePoint online
    • Uncategorized
    • Uncategorized
  • PowerAutomate
Rishan Solutions
Latest Posts
  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025 June 24, 2025
  • Recursive Queries in T-SQL May 7, 2025
  • Generating Test Data with CROSS JOIN May 7, 2025
  • Working with Hierarchical Data May 7, 2025
  • Using TRY_CAST vs CAST May 7, 2025
  • Dynamic SQL Execution with sp_executesql May 7, 2025

Bulk Uploading Metadata Files to SharePoint Online using PnP PowerShell

Posted on March 21, 2025March 21, 2025 by Rishan Solutions

Loading

Uploading multiple files with metadata to SharePoint Online can be time-consuming if done manually. PnP PowerShell allows bulk uploading with metadata updates efficiently.

This guide will cover:
✔ Connecting to SharePoint Online
✔ Uploading multiple files to a document library
✔ Applying metadata to the uploaded files
✔ Automating the process


Step 1: Install and Connect to SharePoint Online

Ensure PnP PowerShell is installed:

Install-Module -Name PnP.PowerShell -Force -AllowClobber

Update the module if needed:

Update-Module -Name PnP.PowerShell

Now, connect to your SharePoint site:

Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/YourSite" -Interactive

✔ Uses interactive login for authentication.


Step 2: Prepare Metadata in a CSV File

Create a CSV file (metadata.csv) with the following format:

FileNameLibraryNameTitleCategoryDepartment
file1.pdfDocumentsReport Q1FinanceHR
file2.xlsxReportsSales DataSalesMarketing
file3.docxPoliciesGuidelinesComplianceLegal

✔ Ensure this CSV is stored in the same directory as the script.


Step 3: Bulk Upload Files and Apply Metadata

Run the following script to upload files and set metadata:

# Define CSV and local folder containing files
$csvFile = "C:\Path\To\metadata.csv"
$localFolder = "C:\Path\To\Files"

# Read metadata CSV
$files = Import-Csv -Path $csvFile

# Loop through each file and upload it with metadata
foreach ($file in $files) {
$filePath = "$localFolder\$($file.FileName)"
$library = $file.LibraryName
$serverRelativeUrl = "/sites/YourSite/$library/$($file.FileName)"

# Upload the file to the specified document library
Add-PnPFile -Path $filePath -Folder $library

# Set metadata
Set-PnPListItem -List $library -Identity $serverRelativeUrl -Values @{
"Title" = $file.Title
"Category" = $file.Category
"Department" = $file.Department
}

Write-Host "Uploaded and tagged: $($file.FileName)"
}

✔ Uploads each file to the respective document library.
✔ Applies metadata from CSV.


Step 4: Automate Bulk Uploading Using Task Scheduler

  1. Save the script as BulkUpload.ps1.
  2. Open Task Scheduler → Create Basic Task.
  3. Set Trigger → Daily or Weekly.
  4. Set Action → Start a Program.
  5. Use this command: -ExecutionPolicy Bypass -File "C:\Scripts\BulkUpload.ps1"

✔ Ensures automated bulk file uploads with metadata.


Step 5: Verify Uploaded Files & Metadata

To check uploaded files:

Get-PnPListItem -List "Documents" | Select-Object FieldValues

✔ Confirms that files are uploaded and metadata is applied.

Posted Under PNP PowerShellBulk Upload Document Management File Metadata Metadata Upload Microsoft 365 PNP PowerShell PowerShell scripting SharePoint Automation SharePoint Governance SharePoint online

Post navigation

Java Kubernetes Operator Framework
Java Distributed Logging and Monitoring

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025
  • Recursive Queries in T-SQL
  • Generating Test Data with CROSS JOIN
  • Working with Hierarchical Data
  • Using TRY_CAST vs CAST

Recent Comments

  1. Michael Francis on Search , Filter and Lookup in power apps
  2. A WordPress Commenter on Hello world!

Archives

  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • March 2024
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • January 2022

Categories

  • Active Directory
  • AI
  • AngularJS
  • Blockchain
  • Button
  • Buttons
  • Choice Column
  • Cloud
  • Cloud Computing
  • Data Science
  • Distribution List
  • DotNet
  • Dynamics365
  • Excel Desktop
  • Extended Reality (XR) – AR, VR, MR
  • Gallery
  • Icons
  • IoT
  • Java
  • Java Script
  • jQuery
  • Microsoft Teams
  • ML
  • MS Excel
  • MS Office 365
  • MS Word
  • Office 365
  • Outlook
  • PDF File
  • PNP PowerShell
  • Power BI
  • Power Pages
  • Power Platform
  • Power Virtual Agent
  • PowerApps
  • PowerAutomate
  • PowerPoint Desktop
  • PVA
  • Python
  • Quantum Computing
  • Radio button
  • ReactJS
  • Security Groups
  • SharePoint Document library
  • SharePoint online
  • SharePoint onpremise
  • SQL
  • SQL Server
  • Template
  • Uncategorized
  • Variable
  • Visio
  • Visual Studio code
  • Windows
© Rishan Solutions 2025 | Designed by PixaHive.com.
  • Rishan Solutions