# set folder path
$dump_path = "C:\shares\*"
$Eliminate = @("*dump*", "*Perform")
# set min age of files
#$max_days = "-2" | Where-Object { $_.LastWriteTime -lt $del_date }
# get the current date
#$curr_date = Get-Date
# determine how far back we go based on current date
#$del_date = $curr_date.AddDays($max_days)
# delete the files
Remove-Item -Recurse C:\shares\* -exclude $Eliminate
答案 0 :(得分:0)
你可以这样做:
Get-Childitem C:\shares -recurse | where {($_.creationtime -gt $del_date) -and ($_.name -notlike "*dump*" -and $_.name -notlike "*perform*")} | remove-item
此刻我有点生疏,所以有人可能会提出更优雅的解决方案