Fixing Blank Sensitivity Label Columns in SharePoint Views After Programmatic update
Problem Statement
Mass applying sensitivity labels programmatically using Microsoft Information Protection SDK (MIP SDK) or PowerShell, the sensitivity label column appears blank in the document library UI, even though the metadata value is correctly set in the backend.

This is a display refresh issue where the applied sensitivity labels has not synced to the SharePoint metadata.
Root Cause
When sensitivity labels are applied programmatically (via PowerShell, Graph API, or migration tools), the metadata is present in the file but not displayed in the interface.
Manual Workarounds
These UI-based actions force a refresh but have significant drawbacks for bulk operations:
Option 1: Open Details Pane
Steps: Click on a file → Click “Details” icon (ℹ️) in the top ribbon

Impact: ✅ Refreshes display without modifying file
Option 2: Copy Link
Steps: Right-click file → Select “Copy link”

Impact: ✅ Triggers UI refresh without file modification
Note: Careful not to create unnecessary sharing links if default sharing is not set to ‘Only people withexisting access’
Option 3: Open File
Steps: Open the file in browser or desktop client
Impact: ⚠️ May trigger auto-save, affecting metadata integrity (Modified, Modified By)
Limitations of Manual Workarounds
| Issue | Description |
|---|---|
| 📊 Scale | Not feasible for hundreds or thousands of files |
| ⏱️ Time | Extremely time-consuming for large libraries |
| 🔄 Metadata Integrity | Opening files may alter “Modified” and “Modified By” fields |
| 👤 User Dependency | Requires manual intervention for each file |
Automated Solution: PowerShell Script
The alternative workaround which I figured out is to just try to getsharinginformation using the REST API endpoint to trigger the refresh.
# Connect to SharePoint
$clientId = "xxxxxxxxxxxxx"
function Get-FilteredSharingInfo {
param (
[string]$siteUrl,
[string]$lib
)
# Connect to SharePoint
Connect-PnPOnline -Url $siteUrl -ClientId $clientId
# Get all items from the specified library
$items = Get-PnPListItem -List $lib -PageSize 1000
# Filter for Office and PDF files only
$filteredItems = $items | Where-Object {
$_['FileLeafRef'] -match "\.(docx|xlsx|pptx|pdf|doc|xls|ppt)$" -and
-not $_['_DisplayName']
}
# Loop through filtered items and call REST API for sharing info
foreach ($item in $filteredItems) {
$itemId = $item.Id
$url = "$siteUrl/_api/web/getlistbytitle('$lib')/GetItemById($itemId)/GetSharingInformation"
try {
Invoke-PnPSPRestMethod -Method Get -Url $url | Out-Null
Write-Host "Item ID: $itemId - Sharing Info Retrieved"
# Optionally process or export $response here
}
catch {
Write-Warning "Failed to retrieve sharing info for item ID $itemId"
}
}
}
Get-FilteredSharingInfo -siteUrl "https://contoso.sharepoint.com/sites/test" -lib "Documents"
How the Script Works
The script triggers SharePoint’s metadata refresh mechanism by:
- Connecting to the SharePoint site using PnP PowerShell
- Filtering items to only Office documents and PDFs without existing display names
- Invoking the
GetSharingInformationREST API endpoint for each file - Triggering the UI refresh without modifying file metadata
This approach is non-invasive and doesn’t affect:
- File modification dates
- Version history
- “Modified By” metadata
- Sharing permissions
How to run Update Script Parameters
Replace the following values in the script:
$clientId: Your Entra ID app registration client ID$siteUrl: Your SharePoint site URL$lib: Your document library name
Step 4: Verify Results
After running the script:
- Refresh your browser
- Check the Sensitivity Label column in the document library
- Labels should now be visible for all processed files
Expected Outcomes
| Before Script | After Script |
|---|---|
| ❌ Sensitivity column blank | ✅ Labels displayed correctly |
| ⚠️ Metadata only in file properties | ✅ Metadata synced to SharePoint UI |
| 🔄 Manual refresh required per file | ✅ Bulk refresh completed |
Enhanced Logging
For detailed troubleshooting, add logging to the script:
# Add at the beginning of the function
$logFile = "C:\Temp\SensitivityLabelRefresh_$(Get-Date -Format 'yyyyMMdd_HHmmss').log"
Start-Transcript -Path $logFile
# Add at the end of the function
Stop-Transcript
Conclusion
This PowerShell solution provides a reliable, automated way to refresh sensitivity label displays in SharePoint after programmatic label application. While it’s a workaround for a display synchronization issue, it’s currently the most effective method for bulk operations without affecting file metadata.
If Microsoft provides an official API or solution for this issue in the future, this post will be updated accordingly.
Community Feedback
Have you encountered this issue? Found a better solution? Share your experience in the comments or reach out via the contact page.
References
Microsoft Purview Information Protection