Update URL Fields with PnP PowerShell

I have been working on a client’s project using Azure Automation and Flow to stitch together a solution for easily managing default column metadata in SharePoint Online. (More on that later.) I am using the PnP PowerShell to handle the heavy lifting in my automation scripts. One component I was struggling with was writing complex values back to the list that originates the flow. Specifically, I encountered issues when setting the value of a SPUrl field when the URL contains a comma. If you try this as a string, SharePoint will split on the first comma it finds. Anyway, to my delight I discovered that you can pass a FieldUrlValue object and it works quite nicely. So hopefully this will help others:

$urlValue = New-Object Microsoft.SharePoint.Client.FieldUrlValue 
$urlValue.Url = $urlToFolder
$urlValue.Description = $folderName 
$values = @{"MyFolderUrl"=[Microsoft.SharePoint.Client.FieldUrlValue]$urlToFolder }
Set-PnPListItem -List $list -Identity $itemID -Values $values

About Matthew McDermott