1

I am wondering if anyone can provide me a script to report on "last modified" files in a specific site and, if possible, output it to CSV so that I can open and report it in Excel.

I need to show this report to my boss so that we can proceed with a content overhaul of this site.

1 Answer 1

1

I used the following script to check last modified time for all lists. It was used for content reviewing before the migration. It doesn't export each file modification time and shows only the most recent time of changes, but probably it helps you. You can change "2013-06-01" to any other date, the lists which were modified after that date will be marked with "+++" in CSV file.

$webcount = 0 $listcount = 0 $outputPath = "C:\tmp\lists.csv" $outputPath2 = "C:\tmp\webs.csv" $webs = (Get-SPSite -limit all | Get-SPWeb -Limit all -ErrorAction SilentlyContinue) if($webs.count -ge 1 -OR $webs.count -eq $null) { foreach($web in $webs) { #Grab all lists in the current web $lists = $web.Lists Write-Host "Website"$web.url -ForegroundColor Green if($WriteToFile -eq $true){ $dw=Get-Date $web.LastItemModifiedDate -format d $cr=Get-Date $web.Created -format d if ($web.LastItemModifiedDate -ge (get-date 2013-06-01)){ Add-Content -Path $outputPath -Value "W;+++;$($web.url);$($web.Lists.Count);;$($web.WebTemplate);$dw;$cr;$($web.Fields.Count);$($web.ContentTypes.Count)" } else { Add-Content -Path $outputPath -Value "W;---;$($web.url);$($web.Lists.Count);;$($web.WebTemplate);$dw;$cr;$($web.Fields.Count);$($web.ContentTypes.Count)" } Add-Content -Path $outputPath2 -Value "Website $($web.url);$($web.Lists.Count);;$($web.WebTemplate);$dw;$($web.SiteAdministrators);$($web.Description);$($web.Fields.Count);$($web.ContentTypes.Count)" } foreach($list in $lists) { $d=Get-Date $list.LastItemModifiedDate -format d $listcount +=1 Write-Host " – "$list.Title if ($list.LastItemModifiedDate -ge (get-date 2013-06-01)){ Add-Content -Path $outputPath -Value "L;+++;$($list.Title);$($list.ItemCount);$($list.Hidden);$($list.BaseTemplate);$d;$($list.Description)" } else { Add-Content -Path $outputPath -Value "L; - ;$($list.Title);$($list.ItemCount);$($list.Hidden);$($list.BaseTemplate);$d;$($list.Description)" } if($WriteToFile -eq $true){} } $webcount +=1 $web.Dispose() } #Show total counter for checked webs & lists Write-Host "Amount of webs checked:"$webcount Write-Host "Amount of lists:"$listcount } else { Write-Host "No webs retrieved, please check your permissions" -ForegroundColor Red -BackgroundColor Black } 
5
  • the script needs to report on the files "modified date" - not on the lists themselves. Commented Mar 17, 2014 at 13:54
  • it is possible to narrow the scope to a site? Commented Mar 17, 2014 at 14:41
  • managed to do it by modifying this line: $webs = (Get-SPWeb 'rootsite/mysite' -ErrorAction SilentlyContinue) Commented Mar 17, 2014 at 15:03
  • what is the purpose of "-OR $webs.count -eq $null" in the initial If statement? Seems like if the count of web is null you don't want to be looping through webs. Commented Mar 17, 2014 at 16:53
  • lwebecker2, I get this traversing part somewhere and just adapted it for my needs. Actually, I either noticed this strange part, but decided that probably it was added to not to show false "Permissions issue" if a user has access, but there is no webs, so I decided not to remove it just in case, because it worked well for me and I was not sure whether this part correct ot not. Commented Mar 18, 2014 at 6:44

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.