Finding modified date of a file/folder

后端 未结 5 1121
执笔经年
执笔经年 2020-12-09 02:04

I am very new to PowerShell, and I was hoping I could get some help creating a script that tells me the modified date of a file.

I wish I knew more about PowerShell,

5条回答
  •  再見小時候
    2020-12-09 02:39

    If you run the Get-Item or Get-ChildItem commands these will output System.IO.FileInfo and System.IO.DirectoryInfo objects that contain this information e.g.:

    Get-Item c:\folder | Format-List  
    

    Or you can access the property directly like so:

    Get-Item c:\folder | Foreach {$_.LastWriteTime}
    

    To start to filter folders & files based on last write time you can do this:

    Get-ChildItem c:\folder | Where{$_.LastWriteTime -gt (Get-Date).AddDays(-7)}
    

提交回复
热议问题