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"
$list.Update()
Invoke-PnPQuery

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:

One thought on “Updating SharePoint Online List Icons with PowerShell”

  1. Hello great article thanks! 🙂
    Does this also work on SharePoint 2019 on Premise?

    Since after migration from previous versions we are encountering the same problem.
    The idea is of a PowerShell Script which replaces every image to .png, as mentioned by you, for each app on each existing site.

    SharePoint 2019 on Premise does also have the same newer Icons as on SP Online.

    Many Thanks for your reply.

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.