delete CBS.log if the archive space is >200MB
This commit is contained in:
@@ -28,6 +28,16 @@ If ( IsAdmin )
|
||||
$CBSLogs = Get-ChildItem -Path "${Env:SystemRoot}\Logs\CBS\*" -File -Include "CbsPersist_*.log", "CbsPersist_*.cab"
|
||||
If ( $CBSLogs )
|
||||
{
|
||||
$TotalBytes = 0
|
||||
ForEach ( $CBSLog in $CBSLogs) { $TotalBytes += $CBSLog.Length }
|
||||
$TotalSize = $TotalBytes / 1MB
|
||||
If ( $TotalSize -ge 200 ) {
|
||||
LogMsg "Total CBS log archive size: ${TotalSize}MB"
|
||||
Control-Service -Stop 'TrustedInstaller'
|
||||
LogMsg "Deleting primary CBS.log file"
|
||||
Remove-Item "${Env:SystemRoot}\Logs\CBS\CBS.log" -Force -ErrorAction SilentlyContinue }
|
||||
Control-Service -Start 'TrustedInstaller'
|
||||
}
|
||||
LogMsg "Deleting archived CBS logs from ${Env:SystemRoot}\Logs\CBS"
|
||||
ForEach ( $CBSLog in $CBSLogs ) { Remove-Item $CBSLog -Force -ErrorAction SilentlyContinue }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user