0

I am trying to assigned a variable from a search object :

$tes = $ListLookup.Items | where-object {$_.title -eq "TEST"} | sort Title | FT ID 

So the above brings back the ID of the item I want. But I want to assign that ID number "4" to a variable.

So I can use it in $listLookup = $List.GetItemById(4) as I am trying to get information via that code.

Hope that make sense.

0

If I understand you correctly, to get item ID from filter list, you don't need FT(format).

#Set config variables
$baseUrl="http://sp:12001/"
$listName ="test"

#Get Web and List Objects
$web = Get-SPWeb $baseUrl
$list = $web.Lists[$listName]
$tes = $list.Items | where-object {$_.title -eq "test"} | sort ID
$ID=$tes[0].ID
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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