This commit is contained in:
2020-09-07 20:47:09 -04:00
parent 45427cea18
commit 092549d358
4 changed files with 23 additions and 25 deletions
-10
View File
@@ -1,10 +0,0 @@
## This script will remove runaway AppX temp files that can consume 100's of GB on an endpoint
## Only run this script on Windows 8 or higher endpoints
#$WindowsVersion = [double]("{0}.{1}" -f ([System.Environment]::OSVersion.Version).Major,([System.Environment]::OSVersion.Version).Minor)
If ( (IsWindowsVersion -ge "6.2") )
{
Write-Output "Cleaning files!"
#Get-ChildItem -Path "${Env:SystemRoot}\Temp" | Where { $_.Name -like "AppXDeploymentServer_*.evtx" }| Remove-Item -Force
#Get-ChildItem -Path "${Env:SystemRoot}\Temp" | Where { $_.Name -like "AppxErrorReport_*.txt" } | Remove-Item -Force
#Get-ChildItem -Path "${Env:SystemRoot}\Temp" | Where { $_.Name -like "AppXPackaging_*.evtx" }| Remove-Item -Force
}
-2
View File
@@ -1,2 +0,0 @@
## This script will delete runaway CBS logs that can take up 100's of GB on an endpoint
Get-ChildItem -Path "${Env:WINDIR}\Logs\CBS" -File | Where { ( $_.Name -like "CbsPersist_*.log" ) -or ( $_.Name -like "CbsPersist_*.cab" ) } | Remove-Item -Force
+23
View File
@@ -0,0 +1,23 @@
## Remove runaway AppX logs;n
If ( (IsWindowsVersion -ge "6.2") )
{
Write-Output "Deleting old AppX log files from ${Env:SystemRoot}\TEMP"
Get-ChildItem -Path "${Env:SystemRoot}\TEMP" | Where { $_.Name -like "AppXDeploymentServer_*.evtx" } | Remove-Item -Force
Get-ChildItem -Path "${Env:SystemRoot}\TEMP" | Where { $_.Name -like "AppxErrorReport_*.txt" } | Remove-Item -Force
Get-ChildItem -Path "${Env:SystemRoot}\TEMP" | Where { $_.Name -like "AppXPackaging_*.evtx" } | Remove-Item -Force
}
## Remove runaway CBS logs
Write-Output "Deleting old CBS log files from ${Env:SystemRoot}\Logs\CBS"
Get-ChildItem -Path "${Env:SystemRoom}\Logs\CBS" -File | Where { ( $_.Name -like "CbsPersist_*.log" ) -or ( $_.Name -like "CbsPersist_*.cab" ) } | Remove-Item -Force
## Remove all system temp files older than the specified number of days
$OlderThan=7
$timedelta = New-TimeSpan -Days $OlderThan
Write-Output "Deleting all files older than ${OlderThan} day(s) from ${Env:SystemRoom}\TEMP"
Foreach ( $item in (Get-ChildItem -Path "${Env:SystemRoot}\TEMP") )
{
## If it's older than the number of days specified, recursively delete the directory
If ( $item.LastWriteTime -lt ((Get-Date) - $timedelta) ) { Remove-Item $item.FullName -Recurse -ErrorAction SilentlyContinue -Force }
}
-13
View File
@@ -1,13 +0,0 @@
## Only delete files older than the following number of days
$OlderThan=7
## Create a new timespan to compare with last write date of the target directory
$timedelta = New-TimeSpan -Days $OlderThan
## Remove all files and directories
Foreach ( $item in (Get-ChildItem -Path "${Env:WinDir}\TEMP") )
{
## If it's older than the number of days specified, recursively delete the directory
If ( $item.LastWriteTime -lt ((Get-Date) - $timedelta) ) { Remove-Item $item.FullName -Recurse -ErrorAction SilentlyContinue -Force }
}