Make temp file age threshold configurable via -TempFileAgeDays parameter
- Default: 3 days (can be overridden via parameter) - Parameter passed to Clear-TempFiles function - Updated menu to show configured threshold
This commit is contained in:
1 parent
d3612914e7
commit
198428cc44
1 file changed
+9
-3
@@ -32,6 +32,9 @@ PC Remediation & Cleanup - Remote Edition
|
||||
.PARAMETER RunAllRemediations
|
||||
Executes all cleanup and maintenance tasks without interactive prompts.
|
||||
|
||||
.PARAMETER TempFileAgeDays
|
||||
Specifies the minimum age (in days) of temporary files to delete. Default: 3 days.
|
||||
|
||||
.PARAMETER Help
|
||||
Displays detailed help information.
|
||||
|
||||
@@ -81,6 +84,9 @@ param (
|
||||
[Parameter(Mandatory=$false)]
|
||||
[switch]$RunAllRemediations,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[int]$TempFileAgeDays = 3,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[switch]$Help
|
||||
)
|
||||
@@ -209,7 +215,7 @@ function Show-Menu {
|
||||
if (-not $Silent) {
|
||||
Write-Host "`nSelect Remediation Action:" -ForegroundColor Yellow
|
||||
Write-Host "1. Clear Windows Update Download Cache" -ForegroundColor White
|
||||
Write-Host "2. Purge System & User Temp Files (3+ days old)" -ForegroundColor White
|
||||
Write-Host "2. Purge System & User Temp Files ($script:TempFileAgeDays+ days old)" -ForegroundColor White
|
||||
Write-Host "3. Clear Windows Error Reporting (WER) Dumps" -ForegroundColor White
|
||||
Write-Host "4. Flush DNS Cache & Reset Network Interfaces" -ForegroundColor White
|
||||
Write-Host "5. Restart Automatic Services That Are Stopped" -ForegroundColor White
|
||||
@@ -244,7 +250,7 @@ function Clear-WindowsUpdateCache {
|
||||
}
|
||||
|
||||
function Clear-TempFiles {
|
||||
param ([string]$TargetComputer = $env:COMPUTERNAME, [Microsoft.Management.Infrastructure.CimSession]$CimSession = $null, [int]$MaxAgeDays = 3)
|
||||
param ([string]$TargetComputer = $env:COMPUTERNAME, [Microsoft.Management.Infrastructure.CimSession]$CimSession = $null, [int]$MaxAgeDays = $script:TempFileAgeDays)
|
||||
Write-ColorOutput "`nPurging Temporary Files (older than $MaxAgeDays days)..." "Yellow" "Info" $TargetComputer
|
||||
|
||||
try {
|
||||
@@ -652,7 +658,7 @@ function Run-AllRemediations {
|
||||
try {
|
||||
Clear-WindowsUpdateCache -TargetComputer $TargetComputer -CimSession $cimSession
|
||||
Clear-WindowsUpdateFiles -TargetComputer $TargetComputer -CimSession $cimSession
|
||||
Clear-TempFiles -TargetComputer $TargetComputer -CimSession $cimSession -MaxAgeDays 3
|
||||
Clear-TempFiles -TargetComputer $TargetComputer -CimSession $cimSession -MaxAgeDays $script:TempFileAgeDays
|
||||
Clear-WerDumps -TargetComputer $TargetComputer -CimSession $cimSession
|
||||
Reset-NetworkStack -TargetComputer $TargetComputer -CimSession $cimSession
|
||||
Repair-StoppedAutomaticServices -TargetComputer $TargetComputer -CimSession $cimSession
|
||||
|
||||
Reference in new issue
Block a user