update
This commit is contained in:
@@ -1,21 +1,27 @@
|
|||||||
## Remove runaway AppX logs;n
|
$SysTemp = "${Env:SystemRoot}\TEMP"
|
||||||
|
|
||||||
|
## Remove runaway AppX logs;n
|
||||||
If ( (IsWindowsVersion -ge "6.2") )
|
If ( (IsWindowsVersion -ge "6.2") )
|
||||||
{
|
{
|
||||||
Write-Output "Deleting old AppX log files from ${Env:SystemRoot}\TEMP"
|
Write-Output "Deleting old AppX log files from ${SysTemp}"
|
||||||
Get-ChildItem -Path "${Env:SystemRoot}\TEMP" | Where { $_.Name -like "AppXDeploymentServer_*.evtx" } | Remove-Item -Force
|
Get-ChildItem -Path $SysTemp | 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 $SysTemp | Where { $_.Name -like "AppxErrorReport_*.txt" } | Remove-Item -Force
|
||||||
Get-ChildItem -Path "${Env:SystemRoot}\TEMP" | Where { $_.Name -like "AppXPackaging_*.evtx" } | Remove-Item -Force
|
Get-ChildItem -Path $SysTemp | Where { $_.Name -like "AppXPackaging_*.evtx" } | Remove-Item -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
## Remove runaway CBS logs
|
## Remove runaway CBS logs
|
||||||
Write-Output "Deleting old CBS log files from ${Env:SystemRoot}\Logs\CBS"
|
$CBSLogDir = "${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
|
If ( Test-Path $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
|
||||||
|
}
|
||||||
|
|
||||||
## Remove all system temp files older than the specified number of days
|
## Remove all system temp files older than the specified number of days
|
||||||
$OlderThan=7
|
$OlderThan=7
|
||||||
$timedelta = New-TimeSpan -Days $OlderThan
|
$timedelta = New-TimeSpan -Days $OlderThan
|
||||||
Write-Output "Deleting all files older than ${OlderThan} day(s) from ${Env:SystemRoom}\TEMP"
|
Write-Output "Deleting all files older than ${OlderThan} day(s) from ${SysTemp}"
|
||||||
Foreach ( $item in (Get-ChildItem -Path "${Env:SystemRoot}\TEMP") )
|
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 }
|
||||||
|
|||||||
Reference in New Issue
Block a user