From c0c490a8b75cc4634113257952410b65f1426994 Mon Sep 17 00:00:00 2001 From: zwnk Date: Thu, 15 Nov 2018 14:08:10 +0100 Subject: [PATCH] Add 'remove stuff' --- remove stuff | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 remove stuff diff --git a/remove stuff b/remove stuff new file mode 100644 index 0000000..aeed499 --- /dev/null +++ b/remove stuff @@ -0,0 +1,19 @@ + +# 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 + } + } +} \ No newline at end of file