使用以下代码行:
get-childitem -Path d:\scripts –recurse |
where-object {$_.lastwritetime -gt (get-date).addDays(-1)} |
Foreach-Object { $_.FullName }
Run Code Online (Sandbox Code Playgroud)
我得到d:\ scripts目录下的所有内容列表,该目录在时间戳中小于1天.输出:
D:\scripts\Data_Files
D:\scripts\Power_Shell
D:\scripts\Data_Files\BackUp_Test.txt
D:\scripts\Power_Shell\archive_test_1dayInterval.ps1
D:\scripts\Power_Shell\stop_outlook.ps1
D:\scripts\Power_Shell\test.ps1
D:\scripts\WinZip\test.wjf
Run Code Online (Sandbox Code Playgroud)
这笔交易是,文件夹(Data_Files和Power_Shell)在日期参数中有最后一次写入.我只想要输出中第3-7行的文件.
建议?