Script to get folder hierichy, file count and required days files in the windows server

sns 8,866 Reputation points

I am looking for folder structure , file count , size , date created and date modified.

file majorily i am looking for a. file less than 30 days b. files less than 1 day c. File greater than 30 days

and finally exporting in to excel.

If there is any script, Please share it, thank you.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,087 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MotoX80 27,376 Reputation points

    There are plenty of examples out on the internet. You will learn a lot more if you do a little searching and try to write it yourself. Then ask a question about what you can't figure out.

    Use this as a reference.

    0 comments No comments

  2. Ian Xue (Shanghai Wicresoft Co., Ltd.) 22,191 Reputation points Microsoft Vendor


    You can get files using the Get-ChildItem cmdlet and filter with a specific file property by Where-Object

    For example, to list the files less than 30 days, you can filter with the LastWriteTime property.

    Get-ChildItem -Path C:\Folder | Where-Object {$_.LastWriteTime -gt $date}

    Best Regards,

    Ian Xue

    If the Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments