Hey everyone! I'm trying to identify all the files on my Windows server that haven't been accessed or modified for a certain period (specifically since a certain month this year). I did find a software option that might work, but I'm really looking for a free solution. Any suggestions on how I can do this?
3 Answers
You can handle this with a simple PowerShell script! Here’s how it works:
```powershell
$date = Get-Date -Year 2025 -Month 3 -Day 1 -Hour 0 -Minute 0 -Second 0
$path = "c:etc"
Get-ChildItem -Path $path -Recurse -File | Where-Object { $_.LastAccessTime -le $date -and $_.LastWriteTime -le $date } | Select-Object Fullname, LastAccessTime, LastWriteTime | Format-Table -Wrap
```
This will list out the files with their last access and write times. Hope that helps!
Thanks a ton! That should cover what I need for now.
Just a thought—what exactly do you mean by 'unused'? Files might not have a reliable indicator of inactivity, but you can check the 'LastAccessTime' property in NTFS for a clue.
Exactly! The LastAccessTime attribute can really help track the last time a file was used.
If you don't mind a bit of cost, Treesize is a good tool to generate detailed reports on your files. It does have a free trial, so you could check it out. Just bear in mind that PowerShell scripting could save you money if you don’t need anything too fancy!
True, while the PowerShell solution is great, Treesize really offers some powerful features for in-depth analysis.
I’ll look into Treesize later, but the PowerShell script works for now!
That's a solid PowerShell command! Couldn’t have said it better myself.