During a recent migration from on-premises SharePoint 2013 to SharePoint Online, we noticed that some of the migrated lists did not use the most recent icons, but rather older ones (from SharePoint 2007 or 2010, I can’t remember whether there was a difference between these two).

For example, the following screenshot shows that all lists except for Tasks use the current icon set:

The question was, can something be done about it? And luckily, it’s an easy fix, as there’s a ImageUrl property present for lists, which stores a link to the image to be used. And as it’s accessible via CSOM, I could write a few lines of PnP Powershell to get the image updated. But update it to what?

Luckily that’s quite simple to figure out and fix as well. The “wrong” icons are .gif files, which have been replaced with the newer .png files. All that needs to be done is basically a replacement of .gif to .png in the link to the image. Here’s an example:

And here’s the corresponding code:

$list = Get-PnPList "Tasks"
$list.ImageUrl = $list.ImageUrl -replace ".gif",".png"

Link to the source code on Github: https://github.com/modery/PnP-Samples/blob/master/Lists/UpdateListIcon.ps1

And finally, here’s how my Site Contents looks like after the change:

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.