liveBook · Manning

Get-PnpListItem

As explained in Practical Automation with PowerShell: Effective scripting from the console to the cloud

Get-PnpListItem is a PnP PowerShell cmdlet that retrieves items from a SharePoint list.

Get-PnpListItem retrieves a SharePoint list item by list name and ID. In request-processing automation, pass the item ID from a watcher script, authenticate in the processing context, and avoid repeating XML queries. section 11.3.3

Use the returned object according to the field type:

  • Read ordinary fields such as Title directly from the item. section 11.3.3
  • Access fields through the item hashtable with square brackets and the field’s internal name. section 11.3.3
  • Resolve lookup fields through their LookupId or related properties; retrieve the referenced template item when its internal name is required. section 11.3.3

Retrieve a site request

$item = Get-PnpListItem -List 'Site Requests' -Id 1 $item['Title'] $item['Author'] $item['Template'] $templateItem = Get-PnpListItem -List 'Site Templates' -Id $item['Template'].LookupId $templateItem['Name'] section 11.3.3

$item = Get-PnpListItem -List 'Site Requests' -Id 1
$item['Title']
$item['Author']
$item['Template']
Posh Tester
 
Email                       LookupId  LookupValue
-----                       --------  -----------
user@<sub>.onmicrosoft.com  6         Matthew Dowst
 
LookupId LookupValue        TypeId
-------- -----------        ------
15 Communication site {f1d34cc0-9b50-4a78-be78-d5facfcccfb7}

Inspect the returned item and observe how ordinary and lookup fields expose their values. section 11.3.3

How Practical Automation with PowerShell: Effective scripting from the console to the cloud covers it

How deep it goes
Explains authentication, ID-based retrieval, hashtable access, and lookup resolution, but not broader query construction.
Examples
Uses Site Requests and Site Templates items, including Title, Author, Template, LookupId, and Name fields.
What it assumes
Assumes a SharePoint list, an item ID, and authentication in the script’s execution context.
What you can do after
Apply it via PnP PowerShell to retrieve an item and resolve its lookup values by ID.
How it connects
Connects SharePoint lists with authentication, lookup fields, site templates, and automated site creation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Practical Automation with PowerShell: Effective scripting from the console to the cloud. The section links point to the parts of the book it draws on.