locked
Find Files By Date Modified RRS feed

  • Question

  • In our environment auditing has never been turned on and I'm looking to change that, but for now I'm trying to work with what I have.

    I'm trying to find a Powershell command I can run that will look at a specific folder and find files with a last modified date older than x. I've seen some scripts to delete files older than x days but I just need to find those files and get a size so I can determine how big of a archive space I need. My plan is to find files that have not been modified in 3-5 years and archive them from my file server. If a file is removed that needs to stay and I can move it back, but I think a lot of this is old data that can just be cleared out from the working drive. So in short I need to find the files and then have the option to move/cut those files to another location once they have been found and I see how much storage I need to make available.

    Thanks in advance!

    Thursday, October 25, 2018 7:16 PM

All replies

  • Look in the Gallery for pre-written scripts.

    This forum is not for script requests.  It is for professional technicians who use PowerShell.  If you need help writing a script you can psot in the "requests" forum.

    This Forum is for Scripting Questions Rather than script requests


    \_(ツ)_/

    Thursday, October 25, 2018 7:59 PM
  • You can riff on something as simple as this:

    $cutoffdate = ([DateTime]::Today).AddDays(-3 * 365) # about three years
    Get-Childitem -path c:\temp -recurse | where {$_.lastwritetime -lt $cutoffdate -and -not $_.PSIsContainer} | select FullName, Length, LastWriteTime, LastAccessTime | export-csv c:\temp\oldstuff.csv -NoTypeInformation
    Adjust your path , cutoff date, and properties as needed.


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Thursday, October 25, 2018 8:19 PM