Last active
November 25, 2019 10:45
-
-
Save JohnLBevan/4c8dae0b5600d566be8024019f898751 to your computer and use it in GitHub Desktop.
Clean Disk Space CBS Logs and CAB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
copy-item 'C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe' 'c:\windows\system32\' | |
copy-item 'C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui' 'c:\windows\system32\en-US\' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Very basic script for this: https://answers.microsoft.com/en-us/windows/forum/windows8_1-files/windows-temp-directory-cab-files-causing-disk/0e534920-f138-492c-a33e-674ba2cb0fe5?tm=1521472940404 | |
function Remove-OldestLargeLogFromCBS { | |
[CmdletBinding(SupportsShouldProcess = $true)] | |
Param ( | |
[Parameter()] | |
[Int64]$FileSize = 2GB | |
, | |
[Parameter()] | |
[DateTime]$LastWriteUtc = (Get-Date '00:00:00').AddDays(-1).ToUniversalTime() | |
) | |
Process { | |
Get-ChildItem -Path (Join-Path -Path $env:SystemRoot -ChildPath 'Logs\CBS') -Filter '*.log' -Force | | |
Where-Object{$_.Length -ge $FileSize} | | |
Where-Object{$_.LastWriteTimeUtc -le $LastWriteUtc} | | |
Sort-Object -Property LastWriteTimeUtc | | |
Select-Object -First 1 | | |
Remove-Item -Force -WhatIf:$WhatIfPreference -Confirm:$ConfirmPreference | |
} | |
} | |
function Remove-AllCABFromTemp { | |
[CmdletBinding(SupportsShouldProcess = $true)] | |
Param ( | |
[Parameter()] | |
[DateTime]$LastWriteUtc = (Get-Date '00:00:00').AddDays(-1).ToUniversalTime() | |
) | |
Process { | |
Get-ChildItem -Path (Join-Path -Path $env:SystemRoot -ChildPath 'Temp') -Filter 'cab*.' -Force | | |
Where-Object{$_.LastWriteTimeUtc -le $LastWriteUtc} | | |
Remove-Item -Force -WhatIf:$WhatIfPreference -Confirm:$ConfirmPreference | |
} | |
} | |
Remove-OldestLargeLogFromCBS -WhatIf | |
Remove-AllCABFromTemp -WhatIf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Temp Files] | |
@="{C0E13E61-0CC6-11d1-BBB6-0060978B2AE6}" | |
"Description"="Temporary Windows system files (typically C:\Windows\Temp)" | |
"Display"="Temporary system files" | |
"Flags"=dword:00000061 | |
"Folder"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,54,00,45,00,4d,00,50,00,00,00 | |
"LastAccess"=dword:00000007 | |
"FileList"="*.*" | |
"StateFlags"=dword:00000000 | |
; source: https://www.dslreports.com/forum/r30520296-Windows-7-delete-files-from-C-Windows-Temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See also MSIZAP
Download: https://www.majorgeeks.com/files/details/windows_installer_cleanup_utility.html
Notes: https://docs.microsoft.com/en-us/windows/win32/msi/msizap-exe
Fix for common issue: https://superuser.com/questions/476910/delete-orphaned-msi-files