After migration and setting the sensitivity label on the migrated content, you may notice that sensitivity label is blank despite the value is set in the metadata.
Three workarounds to force refresh:
Open Details Pane
Copy link
Open file
Open file in browser or desktop
Cons of manually refreshing from the UI
- Due to Auto Save, the file metadata integrity like modified and modified by are affected
- Tedious for large number of files
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"
We had various discussions to no avail with Microsoft to find a solution with a suggestion to trigger a metadata refresh which did not help at all.
If you have any useful workarounds do share.