removed unnecessary variable
This commit is contained in:
@@ -1,7 +1,4 @@
|
|||||||
## Path to the system temp folder
|
## When deleting temp files en masse, only delete files/folders older than the number of days specified here
|
||||||
$SysTemp = "${Env:SystemRoot}\TEMP"
|
|
||||||
|
|
||||||
## When deleting temp files en masse, only delete files/folders older than the number of days specified here
|
|
||||||
$OlderThan = 7
|
$OlderThan = 7
|
||||||
$TimeDelta = New-TimeSpan -Days $OlderThan
|
$TimeDelta = New-TimeSpan -Days $OlderThan
|
||||||
|
|
||||||
@@ -11,18 +8,18 @@ If ( IsAdmin )
|
|||||||
LogMsg "Running with administrative privileges"
|
LogMsg "Running with administrative privileges"
|
||||||
|
|
||||||
## Remove all *.evtx files from $SysTemp
|
## Remove all *.evtx files from $SysTemp
|
||||||
$EventLogs = Get-ChildItem -Path "${SysTemp}\*" -File -Filter *.evtx
|
$EventLogs = Get-ChildItem -Path "${Env:SystemRoot}\TEMP\*" -File -Filter *.evtx
|
||||||
If ( $EventLogs )
|
If ( $EventLogs )
|
||||||
{
|
{
|
||||||
LogMsg "Deleting all event logs from ${SysTemp}"
|
LogMsg "Deleting all event logs from ${Env:SystemRoot}\TEMP"
|
||||||
ForEach ( $EventLog in $EventLogs ) { Remove-Item $EventLog -Force -ErrorAction SilentlyContinue }
|
ForEach ( $EventLog in $EventLogs ) { Remove-Item $EventLog -Force -ErrorAction SilentlyContinue }
|
||||||
}
|
}
|
||||||
|
|
||||||
## Remove misc logs and error reports
|
## Remove misc logs and error reports
|
||||||
$MiscLogs = Get-ChildItem -Path "${SysTemp}\*" -File -Include "${Env:COMPUTERNAME}-*.log", "AppxErrorReport_*.txt"
|
$MiscLogs = Get-ChildItem -Path "${Env:SystemRoot}\TEMP\*" -File -Include "${Env:COMPUTERNAME}-*.log", "AppxErrorReport_*.txt"
|
||||||
If ( $MiscLogs )
|
If ( $MiscLogs )
|
||||||
{
|
{
|
||||||
LogMsg "Deleting misc logs from ${SysTemp}"
|
LogMsg "Deleting misc logs from ${Env:SystemRoot}\TEMP"
|
||||||
ForEach ( $MiscLog in $MiscLogs ) { Remove-Item $MiscLog -Force -ErrorAction SilentlyContinue }
|
ForEach ( $MiscLog in $MiscLogs ) { Remove-Item $MiscLog -Force -ErrorAction SilentlyContinue }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,10 +33,10 @@ If ( IsAdmin )
|
|||||||
}
|
}
|
||||||
|
|
||||||
## Remove all system temp files older than 7 days
|
## Remove all system temp files older than 7 days
|
||||||
$OldTempFiles = Get-ChildItem -Path $SysTemp | Where { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) }
|
$OldTempFiles = Get-ChildItem -Path "${Env:SystemRoot}\TEMP" | Where { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) }
|
||||||
If ( $OldTempFiles )
|
If ( $OldTempFiles )
|
||||||
{
|
{
|
||||||
LogMsg "Deleting all temp files not modified in ${OlderThan} day(s) from ${SysTemp}"
|
LogMsg "Deleting all temp files not modified in ${OlderThan} day(s) from ${Env:SystemRoot}\TEMP"
|
||||||
ForEach ( $OldTempFile in $OldTempFiles ) { Remove-Item $OldTempFile -Force -Recurse -ErrorAction SilentlyContinue }
|
ForEach ( $OldTempFile in $OldTempFiles ) { Remove-Item $OldTempFile -Force -Recurse -ErrorAction SilentlyContinue }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user