I am looking for an accurate solution that can identify the inactive sites of the SharePoint Online tenant.

I already checked the different blogs available which suggest using the LastContentModifiedDate or LastItemUserModifiedDate properties but those are not accurate. It does not match with the real scenario I did testing with.

Is there any other way/property available which provides accurate results?

I am open to all kinds of possible solutions i.e., CSOM, PowerShell, Graph API

3 Answers 3


I don't have enough points to add a comment, but this might be worth a try: from PnP.Powershell you can extract information from the audit property of the document (if this isn't correct $site_info below will show you all the information you can get from a site):

$url = "Your site name here"
Connect-PnPOnline -Url $url -Interactive
$site_info = Get-PnPSite
$last_modified = $site_info.audit.context.web.LastItemModifiedDate

Get Inactive SharePoint Online Sites using PowerShell

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$AdminSiteURL ="https://crescent-admin.sharepoint.com"
$CSVFile = "C:\Temp\SiteData.csv"
#Get Credentials to connect
$Cred= Get-Credential
#Connect to Admin Center
Connect-SPOService -Url $AdminSiteURL -Credential $Cred
#Get All Site Collections
$Sites = Get-SPOSite -Limit All 
$SiteData = @()
#Loop through each site collection
ForEach($Site in $Sites)
    Write-host -f Yellow "Getting Data for Site:" $Site.URL
    Try { 
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Site.URL)
        $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
        #Get the Root Web
        $Web = $Ctx.web
        #Get the last modified date of the site
        $SiteData += New-Object PSObject -Property @{
            SiteTitle = $Web.Title
            URL = $Web.Url
            LastModified= $Web.LastItemUserModifiedDate
    Catch {
        write-host -f Red "Error:" $_.Exception.Message
#Export the results to CSV
$SiteData | Export-CSV $CSVFile -NoTypeInformation

Reference https://www.sharepointdiary.com/2019/08/sharepoint-online-find-unused-sites-using-powershell.html


Agree it is confusing. I did research on properties below:

  • LastContentModifiedDate Site property
  • LastItemModifiedDate Web property
  • LastItemUserModifiedDate Web property
  • LastModifiedDateTime MS Graph site property

In terms of what event triggers which property, and Here are the results

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.