I simply want to update a hyperlink field via Powershell:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
.
.
.
$newPTH = $newBaseURL + $filenameSTR;
$linkOBJ = New-Object Microsoft.SharePoint.SPFieldUrlValue
$linkOBJ.Url = $newPTH
$linkOBJ.Description = $itemOBJ['Product_x0020_Specification'].Description
$itemOBJ['Product_x0020_Specification'] = [Microsoft.SharePoint.Client.FieldUrlValue] $linkOBJ;

But I've got the problem that PowerShell won't find the corresponding assembly

Cannot find type [Microsoft.SharePoint.SPFieldUrlValue]

Which assembly do I have to add for that Class? thx

  • what version of CSOM are you using ? Is it onprem or online ? – Gautam Sheth Aug 10 at 9:46
  • It's SharePoint 2016 on prem – Dave Aug 10 at 10:35
up vote 1 down vote accepted

You need to replace Microsoft.SharePoint.SPFieldUrlValue with Microsoft.SharePoint.Client.FieldUrlValue

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
$newPTH = $newBaseURL + $filenameSTR;
$linkOBJ = New-Object Microsoft.SharePoint.Client.FieldUrlValue
$linkOBJ.Url = $newPTH
$linkOBJ.Description = 
$itemOBJ['Product_x0020_Specification'].Description
$itemOBJ['Product_x0020_Specification'] = 
[Microsoft.SharePoint.Client.FieldUrlValue] $linkOBJ;
  • As you are working with Microsoft.SharePoint.Client (CSOM)and Microsoft.SharePoint.SPFieldUrlValue is from (SSOM) Microsoft.SharePoint – Sunil sahu Aug 10 at 10:17
  • You made my day! :-) – Dave Aug 10 at 10:43

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.