Powershell to show file count of modified files

Tagged: ,

This topic contains 2 replies, has 3 voices, and was last updated by Profile photo of Jos Lemmerling Jos Lemmerling 1 month ago.

  • Author
    Posts
  • #56357
    Profile photo of Jay V
    Jay V
    Participant

    Hey all,

    I need to get a number for files modified within a 7day and 30 day period. I'm not bothered about what the file name is or date it was modified just the count.

    Anybody help out?

  • #56359
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    you could use Get-ChildItem and Where-Object to look for the property 'LastWriteTime'

    Or you could search for prewritten scripts in Microsoft Technet Script Gallary

  • #56434
    Profile photo of Jos Lemmerling
    Jos Lemmerling
    Participant

    I was playing around a bit, but I believe this should do the trick:

    (Get-ChildItem | where { $_.LastWriteTime -lt (Get-Date).AddDays(-7) -and $_.LastWriteTime -gt (Get-Date).AddDays(-30)} | measure).Count
    

You must be logged in to reply to this topic.