PowerShell匹配檔案刪除N天前或指定日期(前後)建立(或修改)的檔案
阿新 • • 發佈:2019-01-23
查詢
Get-ChildItem -Path D:\logstash-1.4.2\bin\*.mdmp -Recurse -ErrorAction:SilentlyContinue | `
Where-Object -FilterScript {(((get-date) - ($_.CreationTime)).days -gt 20 `-and $_.PsISContainer -ne $True)} | Select-Object FullName
刪除
Get-ChildItem -Path D:\logstash-1.4.2\bin\*.mdmp -Recurse -ErrorAction:SilentlyContinue | `
-and $_.PsISContainer -ne $True)} | Remove-Item -Force
參考了http://oicu.cc.blog.163.com/blog/static/1230394712011013101555201/,這個文章較為詳細的介紹了,但其沒有告訴你怎麼匹配