$Now = Get-Date
$Days = “68”
$TargetFolder = “D:\SIP\Spool\prod_regprint”
$LastWrite =
N
o
w
.
A
d
d
D
a
y
s
(
−
Now.AddDays(-
Now.AddDays(−Days)
$Files = Get-Childitem $TargetFolder | Where-Object {
.
L
a
s
t
W
r
i
t
e
T
i
m
e
−
l
e
"
_.LastWriteTime -le "
.LastWriteTime−le"LastWrite"}
foreach ( “
F
i
l
e
"
i
n
"
File" in "
File"in"Files” )
{
if ($File -ne $NULL)
{
write-host “Deleting File $File” -ForegroundColor “DarkRed”
Remove-Item $File.FullName | out-null
}
else
{
Write-Host “No more files to delete!” -foregroundcolor “Green”
}
}
Set up schedule and do housekeeping for server automatic
于 2023-02-08 21:17:58 首次发布