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.


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

#Set config variables
$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

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.