Add Thumbnail field in multiple SharePoint sites

Recently I have seen on the community that when you add a column with the internal name of Thumbnail, SharePoint automatically generates a preview of the document. In the post below, we’ll add this column to multiple SharePoint sites that have the list or library that you intend to have the preview of the document. This feature has been requested on the SharePoint User Voice.

Replace the below $sites variable with your own sites and the $listName with the name of the document library or list that you intend to add the preview of the document. By default, this code will add to the default view a new column with the thumbnail.

$sites = @("https://contoso.sharepoint.com/sites/demo1",
           "https://contoso.sharepoint.com/sites/demo2")
$listName = "Documents" # NAME OF THE LIST

foreach($site in $sites){			   
	Write-Host "Apply Column to "$site -NoNewline
	Connect-PnPOnline -Url $site -UseWebLogin 
	Add-PnPField -List $listName -DisplayName "Thumbnail" -InternalName "Thumbnail" -Type Text -AddToDefaultView |Out-Null
	Write-Host "Done" 
}		

It’s also possible to apply this preview of the Documents using the SharePoint Column formatting. You can find the instructions on how to apply this on via that feature in the below link:

Long-time since the lastest time that you update of the PnP PowerShell or the SPO Management Shell? In the below link, you can find on how to update it. It’ll take no more than 2 minutes to have the latest resources.

References

Be First to Comment

Leave a Reply

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