Powershell to show file count of modified files

Welcome Forums General PowerShell Q&A Powershell to show file count of modified files

This topic contains 2 replies, has 3 voices, and was last updated by

 
Participant
2 years, 2 months ago.

  • Author
    Posts
  • #56357

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 421
    Helping Hand
    Rank: Contributor

    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

    Participant
    Points: 0
    Rank: Member

    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
    

The topic ‘Powershell to show file count of modified files’ is closed to new replies.