Hi @SR VSP ,
We can't directly get last modified date of all subsites in a SharePoint tenant.
We can retrieve the last modified date value of all subsites of the given site collection.
#Get Credentials to connect
$Cred= Get-Credential
Function Get-SPOSiteLastModified($SiteURL)
{
Try {
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get the site
$Web = $Ctx.web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()
#Get the last modified date of the site
Write-host "Last Modified Date of $($SiteURL):"$Web.LastItemUserModifiedDate
#Get Subsites of the site
$Webs = $Web.Webs
$Ctx.Load($Webs)
$Ctx.ExecuteQuery()
ForEach($SubWeb in $Webs)
{
#Call the function to get subsite's last modified date
Get-SPOSiteLastModified $SubWeb.URL
}
}
Catch {
write-host -f Red "Error:" $_.Exception.Message
}
}
#Call the function to get last modified date of a site and its subsites
Get-SPOSiteLastModified $SiteURL
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.