Add/Update image columns in SharePoint/Microsoft Lists using PnP PowerShell
In my previous blog about image columns in SharePoint, I explained all you need to know about New Image column type in SharePoint online including how to create an image column, how to add image to a list item, where the Images will be stored, etc.
In this blog, I will explain how to create a new list item with image column and update existing list item to update the image column using PnP PowerShell.
Create new list item with Image column
You can use Add-PnPListItem command in PnP PowerShell to create a new item in SharePoint list with Image column:
# Connect to SharePoint online site
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/spconnect -Interactive
# Get UniqueId of file you're referencing (without this part your image won't appear in Power Apps (browser or mobile app) or Microsoft Lists (iOS app))
$imageFileUniqueId = (Get-PnPFile -Url "SiteAssets/Lists/dbc6f551-252b-462f-8002-c8f88d0d12d5/PnP-PowerShell-Blue.png" -AsListItem)["UniqueId"]
# Create new list item with image column
Add-PnPListItem -List "Logo Universe" -Values @{"Title" = "PnP PowerShell"; "Image" = "{'type':'thumbnail','fileName':'PnP-PowerShell-Blue.png','fieldName':'Image','serverUrl':'https://contoso.sharepoint.com','serverRelativeUrl':'/sites/SPConnect/SiteAssets/Lists/dbc6f551-252b-462f-8002-c8f88d0d12d5/PnP-PowerShell-Blue.png', 'id':'$($imageFileUniqueId)'}"}

Update SharePoint list item with Image column
You can use Set-PnPListItem cmdlet in PnP PowerShell to update existing SharePoint list item with Image column:
# Connect to SharePoint online site
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/spconnect -Interactive
# Get UniqueId of file you're referencing (without this part your image won't appear in Power Apps (browser or mobile app) or Microsoft Lists (iOS app))
$imageFileUniqueId = (Get-PnPFile -Url "SiteAssets/Lists/dbc6f551-252b-462f-8002-c8f88d0d12d5/PnP-PowerShell-Green.png" -AsListItem)["UniqueId"]
# Update SharePoint list item with image column
Set-PnPListItem -List "Logo Universe" -Identity 12 -Values @{"Image" = "{'type':'thumbnail','fileName':'PnP-PowerShell-Blue.png','fieldName':'Image','serverUrl':'https://contoso.sharepoint.com','serverRelativeUrl':'/sites/SPConnect/SiteAssets/Lists/dbc6f551-252b-462f-8002-c8f88d0d12d5/PnP-PowerShell-Green.png', 'id':'$($imageFileUniqueId)'}"}

Note: This blog post is updated based on the updates to PnP script sample at Add/Update Image in SharePoint Image column so that added/updated images will work in Power Apps or Microsoft Lists mobile app.
Learn more
- Add, update, or delete images in SharePoint/Microsoft Lists using Power Apps
- Add/Update image columns in SharePoint lists using CLI for Microsoft 365
- Add an image to SharePoint Image columns using Power Automate
- Power Apps can now display images from SharePoint Online/Microsoft Lists
- Update SharePoint Page Banner Image using PnP PowerShell