标签:查找 powershell 删除
#定义执行的目录 $path = "D:\logfile\" #获取30之前修改的文件列表: Get-ChildItem -Path $path -Recurse -ErrorAction:SilentlyContinue | ` Where-Object -FilterScript {(((get-date) - ($_.LastWriteTime)).days -gt 30 ` -and $_.PsISContainer -ne $False)} | Select-Object FullName #PsISContainer=True is file,False is folder #删除30天之前修改的文件: Get-ChildItem -Path $path -Recurse -ErrorAction:SilentlyContinue | ` Where-Object -FilterScript {(((get-date) - ($_.LastWriteTime)).days -gt 30 ` -and $_.PsISContainer -ne $False)} | Remove-Item -Recurse #删除30天之前修改的文件(包括删除只读、隐藏): #Get-ChildItem -Path D:\test -Force -Recurse -ErrorAction:SilentlyContinue | ` #Where-Object -FilterScript {(((get-date) - ($_.CreationTime)).days -gt 30 ` #-and $_.PsISContainer -ne $True)} | Remove-Item -Force
本文出自 “汜水流年_” 博客,请务必保留此出处http://timefiles.blog.51cto.com/8475652/1855352
标签:查找 powershell 删除
原文地址:http://timefiles.blog.51cto.com/8475652/1855352