Skip to content

Instantly share code, notes, and snippets.

@michaelsanford
Created July 6, 2026 17:41
Show Gist options
  • Select an option

  • Save michaelsanford/9b02da8d059c14f79ac2ca34c9ee62e1 to your computer and use it in GitHub Desktop.

Select an option

Save michaelsanford/9b02da8d059c14f79ac2ca34c9ee62e1 to your computer and use it in GitHub Desktop.
Start-QuickMaintenance.ps1
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