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

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

There are multiple ways
GetItemById()
Get-PnPListItem (PnP)

Use the below PowerShell command to retrieve the 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>)
where,
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])
$context.Load($listItem)
$context.ExecuteQuery()

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


This is not an AI-generated article but is demonstrated by a human.

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!