Link to home
Start Free TrialLog in
Avatar of Michael Green
Michael GreenFlag for Australia

asked on

Producing a list of files modified in last 48 hours on Windows Server 2012

Does anyone have a quick way of producing a list of files modified in the last 48 hours on Windows Server 2012 ?  I need the list in a text file or excel worksheet ......

Happy for a way to do this through the user interface but would really like some way to script the production of this :)
Avatar of Anand Pandya
Anand Pandya

You can try for the software like treesize free version or professional version, which may get you files which are recently modified.
I use Tree Size Pro (as above) and it is useful for your task as well as sorting out disk usage (which is the prime reason I purchased it).
Avatar of Michael Green

ASKER

Sorry Anand and John but I can't see where Tree Size will give me the report I need to see.  Is there something hidden away in the Pro edition ?
Start up Tree Size Pro and then in the right hand Window, click on Age of Files . That does it.

Once you have a graph, you can click on a bar of interest and it brings up an Explorer window of details.

I can get of list of aged files in seconds.
OK - I found a way to do this with the Pro version using the File Search filtering.  

However I was hoping for something I could automate e.g. scripting....

Does anyone have anything ?  Any suggestions other than hand coding a script ?
DIR has the ability to list by date and so you could use Powershell to get files between this date and that date.

You can send a Tree Size scan to an XML, XLS, or CSV with the Export function under File.
John I can't see how DIR can filter by date
DIR won't filter by date, but Powershell is a super set of ordinary commands. I am not a Powershell expert.

I would get the file I need from Tree Size.
Let's stand back.

Open Tree Size on your server, scan the C: drive or whatever, wait of the scan to complete (may take a file minutes), click on the Age of File tab, set your criteria, Export to XSL and you are done.
There will be also trial version for pro available, you can use it to scan the drives for once, if it fulfils your need then you can go ahead with the purchase as it is useful tool.
There are various formats in which you can export the data such as in charts, graphs or in excel sheet i.e. .CSV and can also copy and paste the data as normal.
The simple way is to open a system explorer browser window and user the search field at the top right hand corner and enter "datemodified:yesterday" or select period from calendar dropdown. You will get a list of all the modified files without the need to use third party software.
Avatar of oBdA
Here's a Powershell script that should do the job. You can optionally pass it an include filter ("*.log", "*.txt").
MinAge and MaxAge expect the respective file ages in hours, and if ExportPath is set, it will write a csv file to the path specified here; otherwise the output will be written to the PS pipeline for further processing.
Param(
	[string]$Path = "C:\",
	[array]$Include,
	[int]$MinAge = 0,
	[int]$MaxAge = 48,
	[string]$ExportPath
)
$MinAccess = (Get-Date).AddHours(-$MinAge)
$MaxAccess = (Get-Date).AddHours(-$MaxAge)
$gciArgs = @{}
If ($Include) {
	$gciArgs["Include"] = $Include
}
$Expression = {
	Get-ChildItem -Path $Path -Recurse -File -Force @gciArgs -ErrorAction SilentlyContinue |
		Where-Object {($MaxAccess -le $_.LastWriteTime) -And ($_.LastWriteTime -lt $MinAccess)} | 
		Select-Object -Property FullName, CreationTime, LastWriteTime
}
If ([string]::IsNullOrEmpty($ExportPath)) {
	Invoke-Command -ScriptBlock $Expression
} Else {
	Invoke-Command -ScriptBlock $Expression |
		ForEach-Object {
			$_
			Write-Host -ForegroundColor White "." -NoNewline
		} |
		Export-Csv -Path $ExportPath -NoTypeInformation
	Write-Host -ForegroundColor White "`r`nResults written to '$($ExportPath)'."
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial