get item ID of the last modified item in the SharePoint online list using pnp powershell

g h 716 Reputation points
2020-08-04T06:22:39.797+00:00

I am able to get the date of the last modified item in the list using the script below:

Connect-PnPOnline -Url $SiteURL -Credentials (Get Credentials)

(Get-PnPList -Identity $ListName).LastItemUserModifiedDate
Please help me with getting the Item ID of the above last modified item.

SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,594 questions
0 comments No comments
{count} votes

Accepted answer
  1. g h 716 Reputation points
    2020-08-05T01:32:20.463+00:00

    Found the answer based on search:

    Connect-PnPOnline -Url $SiteURL -UseWebLogin

    Define Query to Filter

    $Query= "<View Scope='RecursiveAll'>
    <Query>
    <Where><Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>1</Value></Eq></Where>
    <OrderBy><FieldRef Name='Modified' Ascending='FALSE' /></OrderBy>
    </Query>
    </View>"

    $ListItems = Get-PnPListItem -List $ListName -Query $Query

    Write-host "Last Modified Item Id:"$ListItems[0].Id


0 additional answers

Sort by: Most helpful