none
SharePoint 2013: Need to get report of all the active and inactive site collections for a web application with last item modified date for each site RRS feed

  • Question

  • Hi All,

    We are planning for migrating SharePoint 2013 sites to SharePoint Online sites. We need to get a list of all Inactive and Active site collections report.

    Some of the sites are very old and have not been modified for last 6 or 10 months. But still in the report it is showing as item modified 2 weeks ago.

    Is there any hidden folder in SharePoint or any other job which automatically runs in background and updates the items in SharePoint site. 

    If so, how can we get the exact or correct Item Modified dates for the sites. Our prime motive is to get the list of active and inactive sites so that we can ignore the inactive sites before migration.

    Could you please help me on this regard as well ?

    Thanks,

    Raj

    Tuesday, July 9, 2019 11:00 AM

Answers

  • Hi,Raj,

    I update the script a bit, please have a try with the new one. Change the output path according to your requirement.

    foreach ($wa in get-spwebapplication )
    {
        foreach ($site in $wa.Sites)
        {
         
    
            foreach ($web in $site.RootWeb)
            {
               $changeQuery = New-Object Microsoft.SharePoint.SPChangeQuery($false, $false);
               $changeQuery.SystemUpdate = $false;
               $changeQuery.List = $true;
               $changeQuery.Item = $true;
               $changeQuery.Folder = $true;
               $changeQuery.Add = $true;
               $changeQuery.Delete = $true;
               $changeQuery.Update = $true;
    
               $spChangeCollection = $web.GetChanges($changeQuery);
    
               $LastItemModifiedDates = New-Object System.Collections.ArrayList
    
               foreach ($change in $spChangeCollection)
               {
                    [void]$LastItemModifiedDates.Add($change.Time);
               }
    
              $a=($LastItemModifiedDates | Measure -Max).Maximum
              $a|  Select @{ L = "URL"; E = { $web.url } }, @{ L = "DateTime"; E = { $_.DateTime } } | Export-Csv -Path c:\export.csv -append
            }
    
        } 
    }

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Raj301189 Wednesday, July 17, 2019 6:45 AM
    Tuesday, July 16, 2019 7:42 AM

All replies

  • yes, it may be modified by timer job also. How exactly you check last modified date for web? Do you use SPWeb.LastItemModifiedDate or something else? If it reports you the date and you think that date is incorrect you may also iterate through all lists in the web and for each list check SPList.LastItemModifiedDate property. In this way you will be able to identify exact list which was update recently and probably got the reason how exactly it was modified.

    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - https://github.com/sadomovalex/camlex

    Tuesday, July 9, 2019 2:26 PM
  • Hi, Raj,

    Just like sadomovalex said, the LastItemModifiedDate may still be affected by system change. According to the replies in this uservoice, the issue may still remain on On-Prem for SP 2013. Try with the SPList.LastItemModifiedDate.

    If that does not work for you. Have a try with the GetChanges methods, as they are supported on on-prem. Reference for SPSite.GetChanges here, other you can find from respective SPSite and SPList objects:

    https://docs.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.spweb.getchanges?view=sharepoint-server#Microsoft_SharePoint_SPWeb_GetChanges_Microsoft_SharePoint_SPChangeQuery_

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, July 10, 2019 3:13 AM
  • Hi Jerry,

    Thanks a lot for your suggestion.

    Could you please help me out with the complete script as i get struck with some command error.

    Thanks,

    Raj

    Wednesday, July 10, 2019 5:40 AM
  • Hi Sadomovalex,

    Thanks a lot for your suggestion.

    Could you please help me out with complete script .

    Thanks,

    Raj

    Wednesday, July 10, 2019 5:41 AM
  • HI Sadomovalex,

    Yes i use SPWeb.LastItemModifiedDate for getting last modified date, which gives me wrong modified dates for site collections.

    Wednesday, July 10, 2019 5:44 AM
  • Hi, Raj,

    Here is a script i edited a  bit from here: https://sharepoint.stackexchange.com/questions/247418/after-cu-sharepoint-splist-last-item-modified-date-is-wrong

    foreach ($wa in get-spwebapplication )
    {
        foreach ($site in $wa.Sites)
        {
            write-host $web
    
            foreach ($web in $site.RootWeb)
            {
               $changeQuery = New-Object Microsoft.SharePoint.SPChangeQuery($false, $false);
               $changeQuery.SystemUpdate = $false;
               $changeQuery.List = $true;
               $changeQuery.Item = $true;
               $changeQuery.Folder = $true;
               $changeQuery.Add = $true;
               $changeQuery.Delete = $true;
               $changeQuery.Update = $true;
    
               $spChangeCollection = $web.GetChanges($changeQuery);
    
               $LastItemModifiedDates = New-Object System.Collections.ArrayList
    
               foreach ($change in $spChangeCollection)
               {
                    [void]$LastItemModifiedDates.Add($change.Time);
               }
    
               write-host ($LastItemModifiedDates | Measure -Max).Maximum
    
            }
    
        } 
    }

    The Output will be like this:

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, July 10, 2019 9:58 AM
  • Hi Jerry,

    Thanks a lot for the script, I did not get a chance to test this script in the farm. Once i test it, i will let you know the outcome.

    Thanks in advance !!

    Regards,

    Raj

    Thursday, July 11, 2019 1:37 PM
  • Hi, Raj,

    After a few days, have you tried the script? Does it work in your environment?

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, July 15, 2019 9:54 AM
  • Hi Jerry,

    Is there a way to get the Output in a Excel or Text file so that i can able to verify the Output. I am able to fetch the results but will be useful if i could get in Excel or Text file.

    THanks,

    Raj

    Tuesday, July 16, 2019 6:49 AM
  • Hi,Raj,

    I update the script a bit, please have a try with the new one. Change the output path according to your requirement.

    foreach ($wa in get-spwebapplication )
    {
        foreach ($site in $wa.Sites)
        {
         
    
            foreach ($web in $site.RootWeb)
            {
               $changeQuery = New-Object Microsoft.SharePoint.SPChangeQuery($false, $false);
               $changeQuery.SystemUpdate = $false;
               $changeQuery.List = $true;
               $changeQuery.Item = $true;
               $changeQuery.Folder = $true;
               $changeQuery.Add = $true;
               $changeQuery.Delete = $true;
               $changeQuery.Update = $true;
    
               $spChangeCollection = $web.GetChanges($changeQuery);
    
               $LastItemModifiedDates = New-Object System.Collections.ArrayList
    
               foreach ($change in $spChangeCollection)
               {
                    [void]$LastItemModifiedDates.Add($change.Time);
               }
    
              $a=($LastItemModifiedDates | Measure -Max).Maximum
              $a|  Select @{ L = "URL"; E = { $web.url } }, @{ L = "DateTime"; E = { $_.DateTime } } | Export-Csv -Path c:\export.csv -append
            }
    
        } 
    }

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Raj301189 Wednesday, July 17, 2019 6:45 AM
    Tuesday, July 16, 2019 7:42 AM
  • Hi Jerry,

    Thanks for the script. I could see some actual results in your script, but it seems like it didnt loop through all the subsites. Is there any alterations need to be done in the script?

    Thanks,

    Raj

    Tuesday, July 16, 2019 11:15 AM
  • Hi, Raj,

    If you want to have a table in sub site level, change the

    foreach ($web in $site.RootWeb)

    to

    foreach ($web in $site.AllWebs)

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, July 17, 2019 1:27 AM
  • Hi Jerry,

    Thanks for the response.

    I am in the process of validating the dates by comparing with the previous report. So, far i could notice some of the sites have actual dates.

    Thanks a lot for your consistent efforts in fine tuning the script and supporting me.

    You are Rock Star :)

    Thanks,

    Raj

    Wednesday, July 17, 2019 6:45 AM