Очистка данных за последние 30 дней каталог число мобильных агентов Co

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Очистка данных за последние 30 дней в каталог
# число мобильных агентов
$Count = 20
# число дней
$Days = "-20"
$CurrentDate = Get-Date
$OldDate = $CurrentDate.AddDays($Days)
do
{
$Path = "D:\DataExchange\"+$Count+"\FromMT\"
Get-ChildItem $Path | Where-Object { $_.LastWriteTime -lt $OldDate } | Remove-Item -Confirm:$false -Force -Recurse
$Path = "D:\DataExchange\"+$Count+"\ToMT\"
Get-ChildItem $Path | Where-Object { $_.LastWriteTime -lt $OldDate } | Remove-Item -Confirm:$false -Force -Recurse
$Path = "D:\DataExchange\"+$Count+"\Logs\"
Get-ChildItem $Path | Where-Object { $_.LastWriteTime -lt $OldDate } | Remove-Item -Confirm:$false -Force -Recurse
# $Count
$Count = $Count - 1
}
while ($Count -gt 0)