
Hi raki-3122,
You could run the following script code in the SharePoint Management Shell as an Admin:
20768-test.txt
Thanks,
Echo Du
----------
@Raki
If the response is helpful, please click "Accept Answer" and upvote it
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
hi,
how to get a report for last two months recent uploaded files from a site collection? so i have site collection and in that site collection i have multiple libraries. i want to iterate through all the libraries and give me the report for all files which has uploaded last two months basically based on date range using powershell?
Note: this is for sharepoint server 2016
Thanks
Hi raki-3122,
You could run the following script code in the SharePoint Management Shell as an Admin:
20768-test.txt
Thanks,
Echo Du
----------
@Raki
If the response is helpful, please click "Accept Answer" and upvote it
hello, you may use SPChangeQuery for that:
var now = DateTime.Now;
foreach (SPList in web.Lists)
{
var start = now.AddMonths(-2);
var end = now;
var changeTokenStart = new SPChangeToken(SPChangeCollection.CollectionScope.List, list.ID, start.ToUniversalTime());
var changeTokenEnd = new SPChangeToken(SPChangeCollection.CollectionScope.List, list.ID, end.ToUniversalTime());
var changeQuery = new SPChangeQuery(false, false);
changeQuery.Item = true;
changeQuery.Add = true;
changeQuery.Delete = false;
changeQuery.Update = false;
changeQuery.ChangeTokenStart = changeTokenStart;
changeQuery.ChangeTokenEnd = changeTokenEnd;
changeQuery.FetchLimit = 1000;
var changes = list.GetChanges(changeQuery);
foreach (SPChangeItem c in changes)
{
SPListItem item = null;
try
{
item = list.GetItemById(c.Id);
}
catch (Exception x)
{
// handle error
continue;
}
// when folder is added item.File is null
if (item == null || item.File == null)
{
continue;
}
Console.WriteLine(item.File.Name);
}
}