How to query and retrieve SharePoint List Item by Itemd ID using PowerShell / Management Shell / PnP PowerShell ?
There are multiple ways
GetItemById()
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>)
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 further to filter and query only required columns/fields.
More Posts related to SharePoint,
- error CAML Query containing special characters
- [Solved] SharePoint Illegal operation attempted on a registry key that has been marked for deletion
- Trigger Flow on selected Listitem from SharePoint view - create button with JSON column formatting
- SharePoint Excel error - The workbook cannot be opened because it contains the following features that are not supported by Excel in the browser
- Send Email with attachment using SharePoint PowerShell, SMTP server
- How to show or hide columns in SharePoint Online List Library from
- SharePoint excel error - A problem occurred while connecting to the server. If the problem continues, contact your administrator.
- How to get SharePoint Online user details from person or group column using REST API
- How to get SharePoint List Item URL using PowerShell
- How to get the SharePoint Tenant Login URL
- Special character & not working with SharePoint REST API
- How to disable SharePoint subsite creation option for owners
- Managed Metadata error - The data returned from the tagging UI was not formatted correctly
- Deploy SharePoint wsp solution package using PowerShell
- How to create classic site in SharePoint Online
- See actual SharePoint error exception modify web.config
- 'Edit Document' Requires a Windows Sharepoint Services-compatible application and Microsoft Internet Explorer 6.0 or higher
- How to enable anonymous public access for SharePoint Online site collection, file, folder without login ?
- SharePoint installation error - Setup is unable to proceed due to the following error This product requires Microsoft .Net Framework 4.5
- How to add animated Gif to SharePoint Online Page
- [Solved] SharePoint Search Internal server error exception
- How to create SharePoint Document Library
- SharePoint - Use Today's Date Time in list view filter and calculated column
- How to redirect SharePoint Site Collection to different URL
- SharePoint error cannot connect to the configuration database
More Posts:
- Jupyter Notebook: 500 Internal Server Error - nbconvert failed: xelatex not found on PATH - Python
- Convert String Date to Date Object in Java - Java
- How to turn off Stage Manager - macOS Ventura - MacOS
- Read a file line by line in Python Program - Python
- JDBCTemplate Querying Examples with Spring Boot 3 - Java
- Display ls command file sizes in KB (kilobytes) MB (megabytes) or GB (gigabytes) [Linux/macOS] - MacOS
- Change Title text for Android Activity using java code - Android
- Java JDBC Connection with Database using SSL (https) URL - Java