cleanup chocolatey cache
This commit is contained in:
@@ -129,6 +129,17 @@ If ( $ShadowCopies.Length -gt 1 ) {
|
||||
}
|
||||
}
|
||||
|
||||
# Delete old temp directories from Chocolatey cache
|
||||
$ChocolateyCache = "${Env:WinDir}\Temp\chocolatey"
|
||||
$ChocolateyTempDirs = Get-ChildItem -Path $ChocolateyCache -Directory -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) }
|
||||
If ( $ChocolateyTempDirs ) {
|
||||
Write-Output "Deleting all temp directories not modified in ${OlderThan} day(s) from ""${ChocolateyCache}"""
|
||||
ForEach ( $d in $ChocolateyTempDirs ) {
|
||||
Try { Remove-Item $d -Force -Recurse -ErrorAction SilentlyContinue }
|
||||
Catch { Write-Error $_.Exception.Message }
|
||||
}
|
||||
}
|
||||
|
||||
# Remove files from user profile directories
|
||||
ForEach ( $userProfile in $(Get-UserProfiles) ) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user