Add 'remove stuff'
This commit is contained in:
parent
3477e11084
commit
c0c490a8b7
1 changed files with 19 additions and 0 deletions
19
remove stuff
Normal file
19
remove stuff
Normal file
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue