Get-PnPSearchCrawlLog Filter to a List or Library

How do you use the Get-PnpSearchCrawlLog cmdlet to check if the SharePoint crawler is indexing your site, list / library, folder, or item / file?

Before you begin, you’ll want to make sure you have access to the Crawl Log: https://yourSite-admin.sharepoint.com/_layouts/15/searchadmin/crawllogreadpermission.aspx

Connect-PnPOnline -Url "https://sharepointed.sharepoint.com/sites/food" -interactive

$logs = Get-PnPSearchCrawlLog  -filter "https://sharepointed.sharepoint.com/sites/food/Lists/tacos/" -RawFormat

foreach($l in $logs)
{
    Write-Host "    "
    Write-Host $l.Url
    Write-Host $l.ItemId
    Write-Host $l.LogLevel
    Write-Host $l.CrawlTime
}

Get-PnPSearchCrawlLog details: https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/get-pnpsearchcrawllog

Other examples:

#get all items crawled in the Shared Documents library
Get-PnPSearchCrawlLog  -filter "https://sharepointed.sharepoint.com/sites/TestSite/Shared Documents/" -RawFormat

#get items in  Folder A
Get-PnPSearchCrawlLog  -filter "https://sharepointed.sharepoint.com/sites/TestSite/Shared Documents/Folder A/" -RawFormat

#check if a single file is indexed
Get-PnPSearchCrawlLog  -filter "https://sharepointed.sharepoint.com/sites/TestSite/Shared Documents/Folder A/test.txt" -RawFormat

#get everything crawled in the past 30 days for a target site
Get-PnPSearchCrawlLog  -filter "https://sharepointed.sharepoint.com/sites/TestSite/" -StartDate (Get-Date).AddDays(-30) -RawFormat

If you receive this error:
Get-PnPSearchCrawlLog: The current connection holds no SharePoint context. Please use one of the Connect-PnPOnline commands which uses the -Url argument to connect.
This means you did not READ the second thing I mentioned at the top of this post. The account running the Get-PnpSearchCrawlLog command will need permission to access the crawl log. You will need to access this site with an admin account or an account with enough permissions to get in trouble:

https://yourSITE-admin.sharepoint.com/_layouts/15/searchadmin/crawllogreadpermission.aspx

Replace yourSite with your tenant’s name.

Leave a Reply

Your email address will not be published. Required fields are marked *