added new removal for outlook backup files
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
. "C:\Users\dyoder\Documents\Emberkom\Data\Projects\development\management-scripts\Tools.ps1"
|
||||
|
||||
# When deleting temp files en masse, only delete files/folders older than the number of days specified here
|
||||
$OlderThan = 7
|
||||
$TimeDelta = New-TimeSpan -Days $OlderThan
|
||||
@@ -184,7 +184,6 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Remove duplicate downloads
|
||||
# Separate the possible duplicates from the rest
|
||||
$PossibleDuplicates = @()
|
||||
@@ -220,6 +219,17 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) {
|
||||
}
|
||||
}
|
||||
|
||||
# Remove old Outlook backup files
|
||||
$OldOutlookBackupFiles = Get-ChildItem -Path "${userProfile}\AppData\Local\Microsoft\Outlook\*" -File -Filter '*.bak' -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) }
|
||||
If ( $OldOutlookBackupFiles ) {
|
||||
LogMsg "Found Outlook backup files older than ${OlderThan} days:"
|
||||
ForEach ( $file in $OldOutlookBackupFiles ) {
|
||||
$path = $file.FullName
|
||||
LogMsg "Deleting: ""${path}"""
|
||||
Try { Remove-Item -Path $path -Force -ErrorAction SilentlyContinue }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Silently run cleanmgr.exe with default settings
|
||||
|
||||
Reference in New Issue
Block a user