As a SharePoint admin, you’ll often get a requirement to fill in columns on many files at once. PnP PowerShell can do it without opening each properties pane.
In this tutorial, we’ll use PnP PowerShell to update file metadata in a SharePoint document library: set columns while uploading, change one existing file by its path, bulk update from a CSV, and keep Modified untouched with SystemUpdate.
Here’s what we’re building. Five contracts, all tagged from one CSV:

Everything below ran on 10/25/2026 in PowerShell 7 with PnP.PowerShell 3.3.0 on our /sites/SPGuides site, and the outputs are real.
Before You Start
You need Edit permission on the library and a PnP connection. If you haven’t registered an app for PnP yet, follow our guide to connect to SharePoint Online with PowerShell first, then run:
Connect-PnPOnline -Url "https://spguides.sharepoint.com/sites/SPGuides" -ClientId "<your-client-id>" -DeviceLogin -PersistLogin
File metadata is the list item behind each file, so every update below is a list item update using internal column names. Our library uses these columns:
| Column | Internal name | Type | Sample value |
|---|---|---|---|
| Department | Department | Choice | Facilities |
| Contract Value | ContractValue | Currency | $18,500 |
| Expiry Date | ExpiryDate | Date only | 06/30/2027 |
| Owner | Owner | Person | admin@spguides.onmicrosoft.com |
Not sure what a column is called internally? This post shows how to get SharePoint column internal names in one line.
Step 1: Create the Contracts Library and Its Columns
Skip this step if you already have a library to practice on.
# Step 1: a document library for contracts, plus four metadata columns
New-PnPList -Title "SPGDemo Contracts" -Url "SPGDemoContracts" -Template DocumentLibrary -OnQuickLaunch | Out-Null
Add-PnPField -List "SPGDemo Contracts" -DisplayName "Department" -InternalName "Department" `
-Type Choice -Choices "Legal","Finance","IT","Facilities","HR" -AddToDefaultView | Out-Null
Add-PnPField -List "SPGDemo Contracts" -DisplayName "Contract Value" -InternalName "ContractValue" `
-Type Currency -AddToDefaultView | Out-Null
Add-PnPField -List "SPGDemo Contracts" -DisplayName "Expiry Date" -InternalName "ExpiryDate" `
-Type DateTime -AddToDefaultView | Out-Null
Set-PnPField -List "SPGDemo Contracts" -Identity "ExpiryDate" -Values @{ DisplayFormat = 0 } # date only
Add-PnPField -List "SPGDemo Contracts" -DisplayName "Owner" -InternalName "Owner" `
-Type User -AddToDefaultView | Out-Null
Get-PnPField -List "SPGDemo Contracts" |
Where-Object InternalName -in "Department","ContractValue","ExpiryDate","Owner" |
Select-Object Title, InternalName, TypeAsString, Required | Format-Table -AutoSize

Checkpoint: Four columns come back with their internal names and Required False.
For more column options, see these tips for customizing SharePoint fields with PnP.
Step 2: Set Metadata While You Upload (Add-PnPFile -Values)
If the values are known at upload time, set them in the same call. Add-PnPFile takes a -Values hashtable of internal names, so the file never sits untagged.
I also add a small helper, Show-Contracts, that prints the library. I reuse it in the later steps:
# Helper: list every contract with its metadata, dates exactly as SharePoint shows them
function Show-Contracts {
Get-PnPListItem -List "SPGDemo Contracts" -Fields FileLeafRef,Department,ContractValue,ExpiryDate,Owner |
Select-Object @{n="File";e={$_["FileLeafRef"]}}, @{n="Department";e={$_["Department"]}},
@{n="Value";e={"{0:C0}" -f $_["ContractValue"]}},
@{n="Expires";e={(Get-PnPProperty -ClientObject $_ -Property FieldValuesAsText)["ExpiryDate"]}},
@{n="Owner";e={$_["Owner"].LookupValue}} | Format-Table -AutoSize
}
# Step 2: upload a file and set its metadata in the same call
$me = (Get-PnPWeb -Includes CurrentUser).CurrentUser.Email
Add-PnPFile -Path "C:\SPGuidesDemo\contracts\Northwind Cleaning Services.txt" -Folder "SPGDemoContracts" -Values @{
Department = "Facilities"
ContractValue = 18500
ExpiryDate = "06/30/2027"
Owner = $me
} | Select-Object Name, ServerRelativeUrl | Format-List
# The other four contracts go up with no metadata (we fill them in later)
Get-ChildItem C:\SPGuidesDemo\contracts -Filter *.txt | Where-Object Name -ne "Northwind Cleaning Services.txt" | ForEach-Object {
Add-PnPFile -Path $_.FullName -Folder "SPGDemoContracts" | Out-Null
}
Show-Contracts

Checkpoint: Northwind Cleaning Services.txt shows Facilities, $18,500, 6/30/2027 and an owner. The other four files have empty columns.
Uploading whole folders? Our guide to upload files to a SharePoint library with PnP PowerShell covers large files and subfolders.
Step 3: Update an Existing File by Its Path
For a file that’s already in the library, get its list item with Get-PnPFile -AsListItem, then pass the item ID to Set-PnPListItem.
# Step 3: update one existing file, found by its server-relative path
$fileUrl = "/sites/SPGuides/SPGDemoContracts/Fabrikam IT Support.txt"
$item = Get-PnPFile -Url $fileUrl -AsListItem -ThrowExceptionIfFileNotFound
"Before: Id={0} Department='{1}' Value='{2}' Version={3}" -f $item.Id, $item["Department"], $item["ContractValue"], $item["_UIVersionString"]
Set-PnPListItem -List "SPGDemo Contracts" -Identity $item.Id -Values @{
Department = "IT"
ContractValue = 42000
ExpiryDate = [datetime]"12/31/2026" # a [datetime], not a string (see Troubleshooting)
} | Out-Null
$item = Get-PnPFile -Url $fileUrl -AsListItem
$text = Get-PnPProperty -ClientObject $item -Property FieldValuesAsText
"After: Id={0} Department='{1}' Value='{2:C0}' Expires={3} Version={4}" -f `
$item.Id, $item["Department"], $item["ContractValue"], $text["ExpiryDate"], $item["_UIVersionString"]

Checkpoint: Before shows empty values; after shows IT, $42,000, 12/31/2026 and the version moves from 3.0 to 4.0.
-Url accepts a server-relative path (/sites/SPGuides/…) or a site-relative one (SPGDemoContracts/…). -ThrowExceptionIfFileNotFound stops the script when the path is wrong; without it you just get nothing back. The same pattern drives all CRUD operations with PnP PowerShell on list items.
Step 4: Bulk Update File Metadata from a CSV
Now the real request: tag the remaining contracts from a spreadsheet. Save it as CSV with the file name in the first column:
FileName,Department,ContractValue,ExpiryDate
Litware Software License.txt,IT,12400,03/31/2027
Adventure Works Catering.txt,HR,7200,09/30/2027
Tailspin Freight Agreement.txt,Finance,56750,01/15/2028
Fabrikam IT Support.txt,IT,42000,12/31/2026
The loop finds each file by name, skips missing ones with a warning, and converts the value and date to real types:
# Step 4: bulk update from a CSV (FileName -> column values)
$library = "SPGDemoContracts"
$owner = (Get-PnPWeb -Includes CurrentUser).CurrentUser.Email
foreach ($row in Import-Csv C:\SPGuidesDemo\contract-metadata.csv) {
$item = Get-PnPFile -Url "$library/$($row.FileName)" -AsListItem
if (-not $item) { Write-Warning "Not found: $($row.FileName)"; continue }
Set-PnPListItem -List "SPGDemo Contracts" -Identity $item.Id -Values @{
Department = $row.Department
ContractValue = [double]$row.ContractValue
ExpiryDate = [datetime]::ParseExact($row.ExpiryDate, "MM/dd/yyyy", $null)
Owner = $owner
} | Out-Null
"Updated: $($row.FileName)"
}
Show-Contracts
Checkpoint: You see four Updated: lines and all five files with a department, value, expiry date and owner.
Person columns take an email or a User Info List ID; separate several people with commas.
Thousands of files? Queue the updates with -Batch as in adding 5,000+ items with PnP batching.
Step 5: Keep Modified and Modified By with SystemUpdate
A metadata cleanup shouldn’t make every file look edited today. -UpdateType controls that. I changed one file three ways and printed Modified and the version after each:
# Step 5: Update vs SystemUpdate - what happens to Modified, Editor and the version?
$fileUrl = "/sites/SPGuides/SPGDemoContracts/Litware Software License.txt"
$item = Get-PnPFile -Url $fileUrl -AsListItem
function Show-Stamp($label) {
$i = Get-PnPFile -Url $fileUrl -AsListItem
"{0,-13} Value={1,8:C0} Modified={2:MM/dd/yyyy HH:mm:ss} Version={3}" -f $label, $i["ContractValue"], $i["Modified"], $i["_UIVersionString"]
}
Show-Stamp "Start"
Set-PnPListItem -List "SPGDemo Contracts" -Identity $item.Id -Values @{ ContractValue = 12600 } -UpdateType SystemUpdate | Out-Null
Show-Stamp "SystemUpdate"
Set-PnPListItem -List "SPGDemo Contracts" -Identity $item.Id -Values @{ ContractValue = 12900 } -UpdateType Update | Out-Null
Show-Stamp "Update"

Checkpoint: SystemUpdate changed the value from $12,400 to $12,600, but Modified stayed at 04:39:54 and the version stayed 7.0. Update moved Modified to 04:43:50 and created version 8.0.
| -UpdateType | New version? | Modified / Modified By | Flows triggered? |
|---|---|---|---|
| Update (default) | Yes, if versioning is on | Updated to now / you | Yes |
| SystemUpdate | No, appended to the last version | Kept | No |
| UpdateOverwriteVersion | No | Modified updated (tested) | Yes |
Test the Updates
Run Show-Contracts again and compare it with the CSV row by row, then open Version history on the SystemUpdate file: no new version appears for that change.
Make It Production-Ready
- Use internal names as the -Values keys; the display name Contract Value failed in our test.
- Convert types:
[double]for numbers and[datetime]::ParseExact()for dates. - Test on a copy of the library first; SystemUpdate leaves no new version to roll back to.
- Check the file exists before updating; see check if a file exists in SharePoint.
Troubleshooting
The date is one day early
This one surprised me. Set-PnPListItem treated a date string as UTC midnight, so on our Pacific-time site 01/15/2028 was saved as 4:00 PM the day before. A [datetime] value landed on the right day:
$fileUrl = "/sites/SPGuides/SPGDemoContracts/Tailspin Freight Agreement.txt"
$item = Get-PnPFile -Url $fileUrl -AsListItem
$tests = [ordered]@{
'String "01/15/2028"' = "01/15/2028"
'[datetime]"01/15/2028"' = [datetime]"01/15/2028"
}
foreach ($label in $tests.Keys) {
Set-PnPListItem -List "SPGDemo Contracts" -Identity $item.Id -Values @{ ExpiryDate = $tests[$label] } | Out-Null
$saved = Get-PnPFile -Url $fileUrl -AsListItem
$shown = (Get-PnPProperty -ClientObject $saved -Property FieldValuesAsText)["ExpiryDate"]
"{0,-26} -> stored {1:MM/dd/yyyy HH:mm} site time, SharePoint shows {2}" -f $label, $saved["ExpiryDate"], $shown
}

Add-PnPFile -Values stored the string 06/30/2027 correctly in Step 2, but I pass [datetime] values to both cmdlets to be safe.
“Not checked out” and required columns
With Require Check Out on, updating a checked-in file fails with “is not checked out. You must first check out this document before making changes.” If a required column is empty, check-in fails with “You must fill out all required properties before checking in this document.”

The fix is check out, set every required column, then check in:
$fileUrl = "/sites/SPGuides/SPGDemoContracts/Adventure Works Catering.txt"
$item = Get-PnPFile -Url $fileUrl -AsListItem
Set-PnPFileCheckedOut -Url $fileUrl
Set-PnPListItem -List "SPGDemo Contracts" -Identity $item.Id -Values @{ ContractValue = 7600; Department = "HR" } | Out-Null
Set-PnPFileCheckedIn -Url $fileUrl -CheckinType MajorCheckIn -Comment "Contract value updated by script"
- Column ‘Contract Value’ does not exist: that’s the display name. Use the internal name, ContractValue.
- Nothing happens for one row: the file name in the CSV doesn’t match; the loop prints a warning.
Where to Take It Next
Export current metadata first so you have a backup; download all files from a document library pairs well with that. Need to tag new files as they arrive instead? Run the Step 2 pattern from a scheduled script, or see how to add SharePoint list items with PnP PowerShell for every column type.
More PnP PowerShell guides for SharePoint libraries and lists:
Frequently Asked Questions
How do I update file metadata in SharePoint with PnP PowerShell?
Get the file’s list item with Get-PnPFile -Url with the file path and -AsListItem, then run Set-PnPListItem -List with the library name, -Identity $item.Id -Values @{ Column = value } using internal column names.
Can I set metadata while uploading a file?
Yes. Add-PnPFile has a -Values hashtable, so the file is uploaded and tagged in one call.
How do I update metadata without changing Modified and Modified By?
Use -UpdateType SystemUpdate. The Set-PnPListItem docs say it doesn’t create a new version and doesn’t update Modified or Modified By; in our test both stayed the same.
Why is my date one day off after Set-PnPListItem?
A date string is treated as UTC, so sites west of UTC show the previous day. Pass a [datetime] value, for example [datetime]::ParseExact($date, “MM/dd/yyyy”, $null).
Can I update metadata for files in a subfolder?
Yes. Use the full path in Get-PnPFile -Url, such as /sites/SPGuides/SPGDemoContracts/2026/Lease.docx; the folder doesn’t change how Set-PnPListItem works.

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.