Forum Discussion

Istvan Ybema's avatar
Istvan Ybema
Copper Contributor
Jun 10, 2020

LastContentModifiedDate using PowerShell not equal to actual date in SharePoint Admin

I've created a report using PowerShell to get an overview of inactive SharePoint Sites using the LastContentModifiedDate property of the SharePoint object.

 

 

But when I compare the date to the last modified in the SharePoint Admin I'm getting a different date.
It looks like the LastContentModifiedDate is nog reflecting the correct date.


Tried this on different Tenants and SharePoint sites. Is this correct of is there a better way to get the Last-Content-Modified date using powershell?

2 Replies

  • Istvan Ybema 

    Apparently that date gets update by some kind of timer job.
    You can find the correct date with the LastItemUserModifiedDate property of the web object.

     

    $oWeb = Get-PnPWeb -Includes LastItemUserModifiedDate
    $oContentModifiedDate = $oWeb.LastItemUserModifiedDate

     

     

    • tcboeira's avatar
      tcboeira
      Copper Contributor
      What would this be like?
      I mean... I looked for how to do it and in the end, via Powershell Script I used 'Get-PnPTenantSite'.
      Basically it is:
      ...
      $DaysInActive = 140
      $SiteCollections = Get-PnPTenantSite
      $Date = (Get-Date).AddDays(-$DaysInActive).ToString("MM/dd/yyyy")
      $InActiveSites = $SiteCollections | Where {$_.LastContentModifiedDate -le $Date} | Select Title, Url, LastContentModifiedDate, Template, StorageMaximumLevel
      $InActiveSites
      ...
      And I always have the same impression. That the date is very close. How can it be done to obtain a more accurate date?

Resources