Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
218 lines (165 sloc) 4.96 KB
external help file applicable schema
SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019, SharePoint Online
2.0.0

Get-PnPListItem

SYNOPSIS

Retrieves list items

SYNTAX

By Id

Get-PnPListItem -List <ListPipeBind>
                [-Id <Int>]
                [-Fields <String[]>]
                [-Web <WebPipeBind>]
                [-Connection <SPOnlineConnection>]

By Unique Id

Get-PnPListItem -List <ListPipeBind>
                [-UniqueId <GuidPipeBind>]
                [-Fields <String[]>]
                [-Web <WebPipeBind>]
                [-Connection <SPOnlineConnection>]

By Query

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

All Items

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

-Fields

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

Type: String[]
Parameter Sets: All Items, By Id, By Unique Id

Required: False
Position: Named
Accept pipeline input: False

-Id

The ID of the item to retrieve

Type: Int
Parameter Sets: By Id

Required: False
Position: Named
Accept pipeline input: False

-List

The list to query

Type: ListPipeBind
Parameter Sets: __AllParameterSets

Required: True
Position: 0
Accept pipeline input: True

-PageSize

The number of items to retrieve per page request.

Type: Int
Parameter Sets: All Items, By Query

Required: False
Position: Named
Accept pipeline input: False

-Query

The CAML query to execute against the list

Type: String
Parameter Sets: By Query

Required: False
Position: Named
Accept pipeline input: False

-ScriptBlock

The script block to run after every page request.

Type: ScriptBlock
Parameter Sets: All Items, By Query

Required: False
Position: Named
Accept pipeline input: False

-UniqueId

The unique id (GUID) of the item to retrieve

Type: GuidPipeBind
Parameter Sets: By Unique Id

Required: False
Position: Named
Accept pipeline input: False

-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
Parameter Sets: (All)

Required: False
Position: Named
Accept pipeline input: 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
Parameter Sets: (All)

Required: False
Position: Named
Accept pipeline input: False

OUTPUTS

Microsoft.SharePoint.Client.ListItem

RELATED LINKS

SharePoint Developer Patterns and Practices

You can’t perform that action at this time.