SharePoint PowerShell PnP - How to get list item by Item ID using GetItemById, Get-PnPListItem

How to query and retrieve SharePoint List Item by Itemd ID using PowerShell / Management Shell / PnP PowerShell ?

There are multiple ways
Get-PnPListItem (PnP)

Use below PowerShell command to retrieve SharePoint List Item using the Item ID. This uses GetItemById() which takes in the ItemId as a parameter.

You can modify the below code for other requirements but the core logic remains the same.

Using GetItemById()

$web = Get-SPWeb <SITE URL>
$list = $web.GetList("<LIST NAME>")
$list.GetItemById(<ITEM ID>)
SITE URL = URL of SharePoint Site (string)
LIST NAME = Name of SharePoint List (string)
ITEM ID = Number of Item Id (integer)

Using PnP Get-PnPListItem

Get-PnPListItem -List [List Name] -Id [ID]

Using GetItemById() for SharePoint Online

$list = $Context.web.Lists.GetByTitle("[List Name]")
$listItem = $List.GetItemById([ID])

You can further update the script further to filter and query only required columns/fields.

Recent Posts:

Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.