Home > PowerShell, SharePoint Administration > Getting The Last Modified Date for All List/Document Libraries in a SharePoint 2007 Site Collection using PowerShell

Getting The Last Modified Date for All List/Document Libraries in a SharePoint 2007 Site Collection using PowerShell

If you ever needed to grab a list of all the list and document libraries that were recently last modified on a specific site collection in SharePoint 2007 you can follow the script below.

This might come into handy during a  migration where you would like to see if there were any list or libraries that might have been modified during or after the migration.

——————————————————————————————————————————————————–

#Load SharePoint 2007 Assemblies

[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”) | out-null

$siteUrl=”http://portal/site”
$site=new-object Microsoft.SharePoint.SPSite($siteURL)

#Enter the date you want to compare, leave the date blank if you want the current date.
$date = Get-Date 8/22/2012

foreach($web in $site.AllWebs)
{
    “Site ” + $web.Url >> c:\temp\LastModified.txt
    
    foreach($list in $web.Lists)
    {
        if($list.LastItemModifiedDate -gt $date) #if list item modified date is greater than $date write to text file
        {
            “—-List” + $list.Title >> c:\temp\LastModified.txt
            “——–Last Modified” + $list.LastItemModifiedDate >> c:\temp\LastModified.txt
        }
    }
web.Dispose()
}
site.Dispose()

—————————————————————————————————————————————————–

Advertisements
  1. Fixed
    February 19, 2014 at 10:05 pm

    $web.Dispose()
    $site.Dispose()

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: