1

I see in SharePoint per document the viewers count. I would like to generate a csv report for all my documents in a specific site/library. I try this PowerShell command, but the the properties "ViewsLifetime, ViewsLifetimeUniqueUsers" are empty in my results.

Submit-PnPSearchQuery -Query "* Path:https://myCompany.sharepoint.com/teams/someSpecificSite" -All -TrimDuplicates $False -SelectProperties ViewsLifetime, ViewsLifetimeUniqueUsers, Path

enter image description here

When I try the rest api url I see the properties has a value

https://myCompany.sharepoint.com/teams/someSpecificSite/_api/search/query?querytext='Path:https://myCompany.sharepoint.com/teams/someSpecificSite'&selectproperties='Title,Path,ViewsLifetime,ViewsLifetimeUniqueUsers'

enter image description here

Here is an example of the viewers count of a specific document

enter image description here

1 Answer 1

0

I fix this by my self as follow:

$SiteUrl = "https://myCompant.sharepoint.com/teams/someSite"
$SearchQuery = "Path: https://myCompany.sharepoint.com/teams/someSite/someLibrary"
$CSVFile = "C:\Temp\searchResults.csv"
 
#Connect to PnP Online
Connect-PnPOnline -Url $SiteUrl -Interactive
 
#Execute Search
$SearchResults = Submit-PnPSearchQuery -Query $SearchQuery -All -TrimDuplicates $False -SelectProperties Path, ViewsLifetime,ViewsLifetimeUniqueUsers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.