Created
July 6, 2026 17:41
-
-
Save michaelsanford/9b02da8d059c14f79ac2ca34c9ee62e1 to your computer and use it in GitHub Desktop.
Start-QuickMaintenance.ps1
This file contains hidden or 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
| winget upgrade --all --silent | |
| chkdsk.exe /scan c: | |
| sfc /scannow | |
| DISM /Online /Cleanup-Image /RestoreHealth /StartComponentCleanup | |
| Optimize-Volume -DriveLetter D -ReTrim -NormalPriority -Verbose | |
| $vhds = @($env:USERPROFILE, $env:LOCALAPPDATA, $env:APPDATA) | | |
| ForEach-Object { Get-ChildItem -Path $_ -Recurse -Filter *.vhdx -ErrorAction SilentlyContinue } | | |
| Select-Object -ExpandProperty FullName -Unique | |
| $vhds | | |
| Where-Object { (Get-VHD -Path $_).Attached } | | |
| ForEach-Object { Dismount-VHD -Path $_ } | |
| $vhds | | |
| ForEach-Object -Parallel { Optimize-VHD -Path $_ -Mode Full } -ThrottleLimit 4 | |
| Optimize-Volume -DriveLetter C -NormalPriority -Verbose | |
| Start-ScheduledTask -TaskName "MountDevDrive" | |
| Update-MpSignature | |
| Start-MpScan -ScanType Quick |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment