stuffy_stuff/remove stuff
2018-11-15 14:08:10 +01:00

19 lines
No EOL
577 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# remove old Backups
$backupFileCount = ( Get-ChildItem -Filter *.ova $remoteBackupPath | Measure-Object ).Count
$limitDate = (get-date).AddDays(-12).ToString("yyyMMdd")
$backupPath = "L:\"
if ($backupFileCount -gt 3) {
Get-ChildItem $backupPath |
ForEach-Object {
# get actual
$lasWriteTime = (Get-Content $_.LastWriteTime).ToString("yyMMdd")
# delete backup files older than 12 days
if ($lasWriteTime -lt limitDate ) {
$fileNameFull = Get-Content $_.FullName
Remove-Item path $fileNameFull
}
}
}