Saturday, January 23, 2021

Last Modified date for site collection?

 Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Office.Server.Search.Query”)  


[String]$lastDate = "1/1/2018"


foreach($sc in $webapplication | Get-SPSite -Limit All)

{

    Write-Host $sc.Url -ForegroundColor Yellow


    $keywordQuery = New-Object Microsoft.Office.Server.Search.Query.KeywordQuery($sc)

    $keywordQuery.QueryText = "ContentClass:STS_ListItem AND LastModifiedTime>=$($lastDate) AND site:$($sc.Url)"

    $keywordQuery.RowLimit = 5;

    $searchExec = New-Object Microsoft.Office.Server.Search.Query.SearchExecutor

    $searchResults = $searchExec.ExecuteQuery($keywordQuery)


    If( 0 -eq $searchResults.Table.Count ){

        Write-Host "`tSite Collection $($sc.Url) is old" -ForegroundColor Red


}

No comments:

Post a Comment