The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
Thank you for reaching out to Microsoft Q&A forum support
The reason why you get the behavior some of the metadata values are transferred correctly, while others are not likely stems from a mismatch in the internal Schema XML of the columns between the two tenants. Even if the display names are identical, SharePoint relies on internal GUIDs to map promoted properties.
Since you cannot use migration tools that would typically handle this re-mapping, the most reliable workaround is a two-step process:
- Extract Metadata Locally: Use a client-side PowerShell script to read the custom properties directly from the Word files and export them to a CSV file.
- Bulk Update via Grid View: Upload the documents to the new library, then use the "Edit in grid view" feature in SharePoint to paste the metadata from your CSV file.
You can use the following PowerShell script to extract the properties. Save this code as Extract-Metadata.ps1.
param (
[Parameter(Mandatory=$true)]
[string]$SourcePath,
[string]$OutputCsv = ".\DocumentMetadata.csv"
)
# Load required assembly for ZipFile
Add-Type -AssemblyName System.IO.Compression.FileSystem
$report = @()
# Get all .docx files
$files = Get-ChildItem -Path $SourcePath -Filter "*.docx" -Recurse
foreach ($file in $files) {
$zip = $null
try {
# Open the .docx file as a Zip archive
$zip = [System.IO.Compression.ZipFile]::OpenRead($file.FullName)
# Look for the custom file properties part
$customPropsEntry = $zip.GetEntry("docProps/custom.xml")
if ($customPropsEntry) {
# Read the XML content
$reader = New-Object System.IO.StreamReader($customPropsEntry.Open())
$xmlContent = $reader.ReadToEnd()
$reader.Close()
# Parse XML
[xml]$xml = $xmlContent
# Create an object for the file
$propsObject = [PSCustomObject]@{
FileName = $file.Name
FullPath = $file.FullName
}
# Extract properties
# Namespace manager is needed for accurate parsing, but simple node iteration works for extraction
foreach ($prop in $xml.Properties.ChildNodes) {
$name = $prop.name
# The value is usually in the first child node (e.g., vt:lpwstr, vt:i4)
$value = $prop.FirstChild.InnerText
# Add property to the object
$propsObject | Add-Member -MemberType NoteProperty -Name $name -Value $value -Force
}
$report += $propsObject
}
else {
Write-Warning "File $($file.Name) does not contain custom properties."
}
}
catch {
Write-Error "Failed to process $($file.Name): $_"
}
finally {
if ($zip) { $zip.Dispose() }
}
}
# Export to CSV
# Note: Export-Csv uses the properties of the first object to define columns.
# Ensure the first file processed has all expected properties, or pre-create a dummy file with all properties.
if ($report.Count -gt 0) {
$report | Export-Csv -Path $OutputCsv -NoTypeInformation
Write-Host "Metadata extracted to $OutputCsv"
}
else {
Write-Host "No custom properties found in the specified files."
}
You can follow the detail instructions:
- Save the script above as
Extract-Metadata.ps1. - Run the script in PowerShell, providing the folder path where your downloaded Word documents are located:
.\Extract-Metadata.ps1 -SourcePath "C:\Path\To\MyDocuments" - Open the resulting
DocumentMetadata.csvin Excel.
Upload your Word documents to the new SharePoint library.
In the SharePoint library, click Edit in grid view.
Copy the metadata columns from your Excel CSV and paste them directly into the corresponding columns in the SharePoint grid view. This ensures all properties are populated correctly regardless of the internal schema mismatch.
Hope my answer will help you.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.