added several more logs to delete
This commit is contained in:
@@ -4,18 +4,23 @@
|
|||||||
If ( (IsWindowsVersion -ge "6.2") )
|
If ( (IsWindowsVersion -ge "6.2") )
|
||||||
{
|
{
|
||||||
Write-Output "Deleting old AppX log files from ${SysTemp}"
|
Write-Output "Deleting old AppX log files from ${SysTemp}"
|
||||||
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "AppXDeploymentServer_*.evtx" } | Remove-Item -Force
|
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "AppXDeploymentServer_*.evtx" } | Remove-Item -Force -ErrorAction SilentlyContinue
|
||||||
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "AppxErrorReport_*.txt" } | Remove-Item -Force
|
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "AppxErrorReport_*.txt" } | Remove-Item -Force -ErrorAction SilentlyContinue
|
||||||
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "AppXPackaging_*.evtx" } | Remove-Item -Force
|
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "AppXPackaging_*.evtx" } | Remove-Item -Force -ErrorAction SilentlyContinue
|
||||||
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "Application_*.evtx" } | Remove-Item -Force
|
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "Application_*.evtx" } | Remove-Item -Force -ErrorAction SilentlyContinue
|
||||||
|
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "System_*.evtx" } | Remove-Item -Force -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## Remove computer log files
|
||||||
|
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "Microsoft-Windows-AppReadiness_Admin_*.evtx" } | Remove-Item -Force -ErrorAction SilentlyContinue
|
||||||
|
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "${Env:COMPUTERNAME}-*.log" } | Remove-Item -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
## Remove runaway CBS logs
|
## Remove runaway CBS logs
|
||||||
$CBSLogDir = "${Env:SystemRoot}\Logs\CBS"
|
$CBSLogDir = "${Env:SystemRoot}\Logs\CBS"
|
||||||
If ( Test-Path $CBSLogDir )
|
If ( Test-Path $CBSLogDir )
|
||||||
{
|
{
|
||||||
Write-Output "Deleting old CBS log files from ${CBSLogDir}"
|
Write-Output "Deleting old CBS log files from ${CBSLogDir}"
|
||||||
Get-ChildItem -Path $CBSLogDir -File | Where { ( $_.Name -like "CbsPersist_*.log" ) -or ( $_.Name -like "CbsPersist_*.cab" ) } | Remove-Item -Force
|
Get-ChildItem -Path $CBSLogDir -File | Where { ( $_.Name -like "CbsPersist_*.log" ) -or ( $_.Name -like "CbsPersist_*.cab" ) } | Remove-Item -Force -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
## Remove all system temp files older than the specified number of days
|
## Remove all system temp files older than the specified number of days
|
||||||
@@ -25,6 +30,6 @@ Write-Output "Deleting all files more than ${OlderThan} day(s) old ${SysTemp}"
|
|||||||
Foreach ( $item in (Get-ChildItem -Path "${SysTemp}") )
|
Foreach ( $item in (Get-ChildItem -Path "${SysTemp}") )
|
||||||
{
|
{
|
||||||
## If it's older than the number of days specified, recursively delete the directory
|
## 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 }
|
If ( $item.LastWriteTime -lt ((Get-Date) - $timedelta) ) { Remove-Item $item.FullName -Recurse -ErrorAction SilentlyContinue -Force -ErrorAction SilentlyContinue }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user