Requirement is to find all documents which are uploaded to the SharePoint environment during the past one Month. PowerShell can do the reporting well. Lets see the code:
Same way, we can find all documents uploaded to SharePoint sites based on Date criteria by just checking $item.File.TimeLastModified property. Say For instance,
Find All Documents Created or Modified by a Particular User:
In an another situation, the request is to find all documents either created by modified by a particular user in SharePoint 2007.
| 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 | Add-PSSnapinMicrosoft.SharePoint.PowerShell -ErrorActionSilentlyContinue# Set the date Filter$dateFilter= (Get-Date).AddMonths(-1) #Past Month"File, Created Time, File Size"| out-fileNewDocuments.csv# Get all Webs$webs= Get-SPWebApplication"http://sharepoint.crescent.com"| Get-SPSite-LimitAll | Get-SPWeb-LimitAll#Iterate through websForEach($webin $webs) {   #Iterate through All Lists    ForEach($listin $web.Lists)  {  #Check for Document Libraries          If ($list.BaseType -eq"DocumentLibrary")   {     #Iterate through All documents                   ForEach($itemin $list.Items)   {                  If ($item.URL.StartsWith("_")) {Break} #Skip _catalogs, etc                  If ($item.URL.EndsWith(".aspx")) {Break} #Skip Form pages                    If ($item.File.TimeCreated -ge$dateFilter)     {                      $result= """$($web.URL)/$($item.URL)"", $($item.File.TimeCreated), $( [Math]::Round($item.File.Length/1024,2))"                      $result| Out-FileNewDocuments.csv -Append                 }                }        }    }} | 
Same way, we can find all documents uploaded to SharePoint sites based on Date criteria by just checking $item.File.TimeLastModified property. Say For instance,
- You may be interested to see all old documents created an year back
- All documents which are not changed during the past one year.
Find All Documents Created or Modified by a Particular User:
In an another situation, the request is to find all documents either created by modified by a particular user in SharePoint 2007.
| 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 | [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")#Region MOSS2007-CmdLetsFunction global:Get-SPWebApplication($WebAppURL){  if($WebAppURL-eq$null)  #Get All Web Applications    {  #Sharepoint 2007 powershell spfarm  $Farm= [Microsoft.SharePoint.Administration.SPFarm]::Local  $websvcs= $farm.Services | where-FilterScript{$_.GetType() -eq[Microsoft.SharePoint.Administration.SPWebService]}  $WebApps= @()  foreach($websvcin $websvcs) {      foreach($WebAppin $websvc.WebApplications) {          $WebApps+= $WebApp      }  }  return $WebApps }  else #Get Web Application for given URL {    return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)  } } Function global:Get-SPSite(){  Param( [Parameter(Mandatory=$true)] [string]$SiteCollURL)    if($SiteCollURL-ne'')    {    return new-ObjectMicrosoft.SharePoint.SPSite($SiteCollURL)   }}Function global:Get-SPWeb(){ Param( [Parameter(Mandatory=$true)] [string]$SiteURL)  $site= Get-SPSite($SiteURL)        if($site-ne$null)            {               $web=$site.OpenWeb();            }    return $web}#EndRegion# Set the date Filter"File Name `t Created By `t Modified By `t Created `t Last Modified `t File Size `t URL"| out-fileAllDocsByUser.csv # Get the Web Application #Iterate through site collectionsForEach($sitein $WebApp.Sites)    {     #Iterate through webs     ForEach($webin $site.AllWebs)        {            #Iterate through All Lists            ForEach($listin $web.Lists)            {            #Check for Document Libraries             If ($list.BaseType -eq"DocumentLibrary")               {                #Iterate through All documents                ForEach($itemin $list.Items)                    {                        If ($item.URL.StartsWith("_")) {Break} #Skip _catalogs, etc                        If ($item.URL.EndsWith(".aspx")) {Break} #Skip Form pages                                              If ( ($item.File.Author -like"*domain\user*") -or($item.File.ModifiedBy -like"*domain\user*"))                           {                             $result= "$($item.File.Name) `t $($item.File.Author) `t $($item.File.ModifiedBy) `t $($item.File.TimeCreated) `t $($item.File.TimeLastModified) `t  $( [Math]::Round($item.File.Length/1024,2)) `t $($web.URL)/$($item.URL)"                              $result| Out-FileAllDocsByUser.csv -Append                           }                     }                }           }      }  } | 
Read more: http://www.sharepointdiary.com/2012/09/find-all-documents-created-modified-by-specific-users-datetime.html#ixzz4LfsYdiFH
