Update Hyperlink Field via Powershell (assembly missing)
-
21-01-2021 - |
Question
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
Solution
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;
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange