i am trying to update 2 hyperlink fields (internal names=Hlink1,Hlink2) in powershell,but i am getting "Value does not fall under expected range" error once it hits $Item.SystemUpdate(), but if i remove the $spqQuery.ViewFields it will work fine with out any problem. (below is the code sample)

 $spList = $spWeb.Lists[$List.Title]
                $spqQuery = New-Object Microsoft.SharePoint.SPQuery 
                $spqQuery.Query= "<Query><Where> 
                                    <FieldRef Name='ID'/>
                                    <Value Type='Counter'>1
                $spqQuery.ViewFields = "<ViewFields><FieldRef Name='Title'/><FieldRef Name='Hlink1'/><FieldRef Name='Hlink2'/></ViewFields>"
                $spqQuery.ViewFieldsOnly = $true
                if($spqQuery -ne $null)
                $splListItems = $spList.GetItems($spqQuery) 

                Write-Host $splListItems.Count

            foreach($Item in $splListItems)
                $UrlField= new-object Microsoft.SharePoint.SPFieldUrlValue($Item["Hlink1"])
                $UrlField.Description = $UrlField.Url.ToString()
                $Item[$Field.InternalName]= $UrlField.Description
                $Item["Title"]= "abcd"
  • in above code i cannot see the $true variable you can try with replacing $true to true. at $spqQuery.ViewFieldsOnly = $true
    – Sunil Sahu
    Jul 17, 2018 at 6:23

1 Answer 1


Make sure the field used in $Item[$Field.InternalName] is included in ViewFields definition, if this field is not included in the ViewFields, it will throw Value not fall under expected range.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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