I am trying to add items to the comments list based on the Post list having lookup relation ship between these two lists,can any one give me an example how to update the lookup column values using powershell in sharepoint 2013
1 Answer
You can either use PowerShell formatting to provide a string representation, or create a new SPFieldLookupValue object:
$lookupValueString = "{0};#{1}" -f $post.ID,$post.Title $lookupValue = New-Object Microsoft.SharePoint.SPFieldLookupValue -ArgumentsList $post.ID,$post.Title Then you assign the value to a field and then Update the item.
$comment["PostTitle"] = $lookupValue $comment.Update()