Get-PnPListItem

Retrieves list items

Syntax

Get-PnPListItem
   -List <ListPipeBind>
                  [-Id <Int>]
                  [-Fields <String[]>]
                  [-Web <WebPipeBind>]
                  [-Connection <SPOnlineConnection>]
Get-PnPListItem
   -List <ListPipeBind>
                  [-UniqueId <GuidPipeBind>]
                  [-Fields <String[]>]
                  [-Web <WebPipeBind>]
                  [-Connection <SPOnlineConnection>]
Get-PnPListItem
   -List <ListPipeBind>
                  [-Query <String>]
                  [-PageSize <Int>]
                  [-ScriptBlock <ScriptBlock>]
                  [-Web <WebPipeBind>]
                  [-Connection <SPOnlineConnection>]
Get-PnPListItem
   -List <ListPipeBind>
                  [-Fields <String[]>]
                  [-PageSize <Int>]
                  [-ScriptBlock <ScriptBlock>]
                  [-Web <WebPipeBind>]
                  [-Connection <SPOnlineConnection>]

Examples

------------------EXAMPLE 1------------------

Get-PnPListItem -List Tasks

Retrieves all list items from the Tasks list

------------------EXAMPLE 2------------------

Get-PnPListItem -List Tasks -Id 1

Retrieves the list item with ID 1 from the Tasks list

------------------EXAMPLE 3------------------

Get-PnPListItem -List Tasks -UniqueId bd6c5b3b-d960-4ee7-a02c-85dc6cd78cc3

Retrieves the list item with unique id bd6c5b3b-d960-4ee7-a02c-85dc6cd78cc3 from the tasks lists

------------------EXAMPLE 4------------------

(Get-PnPListItem -List Tasks -Fields "Title","GUID").FieldValues

Retrieves all list items, but only includes the values of the Title and GUID fields in the list item object

------------------EXAMPLE 5------------------

Get-PnPListItem -List Tasks -Query "<View><Query><Where><Eq><FieldRef Name='GUID'/><Value Type='Guid'>bd6c5b3b-d960-4ee7-a02c-85dc6cd78cc3</Value></Eq></Where></Query></View>"

Retrieves all list items based on the CAML query specified

------------------EXAMPLE 6------------------

Get-PnPListItem -List Tasks -PageSize 1000

Retrieves all list items from the Tasks list in pages of 1000 items

------------------EXAMPLE 7------------------

Get-PnPListItem -List Tasks -PageSize 1000 -ScriptBlock { Param($items) $items.Context.ExecuteQuery() } | % { $_.BreakRoleInheritance($true, $true) }

Retrieves all list items from the Tasks list in pages of 1000 items and breaks permission inheritance on each item

Parameters

-Connection

Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type:SPOnlineConnection
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Fields

The fields to retrieve. If not specified all fields will be loaded in the returned list object.

Type:String[]
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Id

The ID of the item to retrieve

Type:Int
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-List

The list to query

Type:ListPipeBind
Position:0
Accept pipeline input:True
Accept wildcard characters:False
-PageSize

The number of items to retrieve per page request.

Type:Int
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Query

The CAML query to execute against the list

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-ScriptBlock

The script block to run after every page request.

Type:ScriptBlock
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-UniqueId

The unique id (GUID) of the item to retrieve

Type:GuidPipeBind
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Web

This parameter allows you to optionally apply the cmdlet action to a subweb within the current web. In most situations this parameter is not required and you can connect to the subweb using Connect-PnPOnline instead. Specify the GUID, server relative url (i.e. /sites/team1) or web instance of the web to apply the command to. Omit this parameter to use the current web.

Type:WebPipeBind
Position:Named
Accept pipeline input:False
Accept wildcard characters:False

Outputs

Microsoft.SharePoint.Client.ListItem