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.

1 Answer 1

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

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.