如何使用 pnp powershell 获取 SharePoint 在线列表中最后修改项目的项目 ID?

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

我可以使用以下脚本获取列表中最后修改项目的日期:

$SiteURL="https://abc.sharepoint.com/sites/sitename"
$ListName="Documents"

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

(Get-PnPList -Identity $ListName).LastItemUserModifiedDate

请帮我获取上面最后修改的项目的项目 ID。

Order by Modified field with desc order 并获取返回项集合的第一项:

$SiteURL= "https://Tenant.sharepoint.com/"
$ListName = "Documents"
 
#Connect to PnP Online
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