Hi,
I am trying to access a multiline text field using powershell. I am tring to use "GetFieldValueAsText" option.
I have tried the below code:
foreach($item in $listItems) { Write-Host $item.Title $calculatedfield = $item.Fields["Test Notes"] -as [Microsoft.SharePoint.SPFieldType]::Note; $item["Test Notes"] = $calculatedfield.GetFieldValueAsText($item["Test Notes"]); $item.SystemUpdate(); }
I am getting the below error:
Cannot convert value "Note" to type "System.Type". Error: "Invalid cast from 'Microsoft.SharePoint.SPFieldType' to 'System.Type'." At \RemoveCharacters.ps1:26 char:9+ $calculatedfield = $item.Fields["Test Notes"] -as [Microsoft. ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : InvalidArgument: (:) [], RuntimeException+ FullyQualifiedErrorId : InvalidCastIConvertible You cannot call a method on a null-valued expression. At \RemoveCharacters.ps1:28 char:9 + $item["Test Notes"] = $calculatedfield.GetFieldValueAsText($i ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : InvalidOperation: (:) [], RuntimeException+ FullyQualifiedErrorId : InvokeMethodOnNull
How to fix this? How to use the option GetFieldValueAsText in powershell for multiline column?
Thanks