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
|| Administration || Office 365 || PnP || PowerShell || SharePoint 2013 || SharePoint 2016

comments powered by Disqus

Let's Get In Touch!


Ready to start your next project with us? That’s great! Give us a call or send us an email and we will get back to you as soon as possible!

+1.512.539.0322