Koldov Posted February 23, 2023 Posted February 23, 2023 I've tried a few from the interwebs, but would rather have one from a trusted source... There are a couple of issues due to a file server share migration messing with the dates. As you can see 'Date accessed' and 'Date created' are very recent unfortunately, but most older files still have 'Date modified' intact. I thought this might be 'LastWriteTime' but whether it isn't or the script I found couldn't transverse the multiple layers of folder depth I don't know, but it didn't return these files... I don't mind changing the script to point to the top level folder each time, but hopefully not each sub-folder (as some have extremely long paths). N.B. Just for clarity I have to do a presentation to SLT on Monday about the issue with the staff drive (and others), just being a free for all dumping ground and would like to have some sort of list of files to highlight the problem.
pfl Posted February 28, 2023 Posted February 28, 2023 (edited) I've tried a few from the interwebs, but would rather have one from a trusted source... There are a couple of issues due to a file server share migration messing with the dates. [ATTACH=CONFIG]68137[/ATTACH] As you can see 'Date accessed' and 'Date created' are very recent unfortunately, but most older files still have 'Date modified' intact. I thought this might be 'LastWriteTime' but whether it isn't or the script I found couldn't transverse the multiple layers of folder depth I don't know, but it didn't return these files... I don't mind changing the script to point to the top level folder each time, but hopefully not each sub-folder (as some have extremely long paths). N.B. Just for clarity I have to do a presentation to SLT on Monday about the issue with the staff drive (and others), just being a free for all dumping ground and would like to have some sort of list of files to highlight the problem. The LastWriteTime should be correct, I found an example that I have slightly modified to traverse a directory of subfolders and files displaying all results in a two column table ("Full Name, Last Write Time") I've set my time ranges to be in months, only displaying files and folders that are older then 30 months but less than 60 months (AddMonths can be changed to other increments if needed eg AddYears,AddDays or AddHours) $table_properties = @{Expression={$_.Fullname};Label="Full Name";width=195}, @{Expression={$_.LastWriteTime};Label="Last Write Time";width=350} Get-ChildItem -Path 'c:\temp\' -recurse -Filter *.* -include *.* | ? {$_.LastWriteTime -lt (Get-Date).AddMonths(-30) }| ? {$_.LastWriteTime -gt (Get-Date).AddMonths(-60)} | Sort-Object -Property LASTWRITETIME -Descending | Format-Table $table_properties Don't forget to change the path 'C:\temp\' its just an example path i used for testing. Edited February 28, 2023 by pfl
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now