Files
FFU/FFUDevelopment/Apps/Orchestration/Run-DiskCleanup.ps1
T
rbalsleyMSFT 08c9d5a0e3 feat: Add progress reporting to FFU build process
Introduces a progress reporting system to provide real-time feedback during the FFU build. This includes adding a progress bar and status messages to the UI, which are updated at key stages of the build process.

- Adds a new `Set-Progress` function to log progress updates.
- Integrates `Set-Progress` calls throughout the main build script.
- Updates the UI to parse progress logs and update the progress bar and status text.
- Improves error reporting in the UI to display more detailed failure reasons.
- Corrects a typo in the `LogicalSectorSizeBytes` parameter name in documentation and log messages.
2025-07-11 16:43:42 -07:00

21 lines
900 B
PowerShell

# Run disk cleanup (cleanmgr.exe) with all options enabled
# Reference: https://learn.microsoft.com/en-us/troubleshoot/windows-server/backup-and-storage/automating-disk-cleanup-tool
$rootKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches"
# Set StateFlags0000 to 2 for all subkeys except "Offline Pages Files"
Get-ChildItem -Path $rootKey | ForEach-Object {
if ($_.PSChildName -ne "Offline Pages Files") {
Set-ItemProperty -Path $_.PSPath -Name "StateFlags0000" -Type DWord -Value 2 -Force
}
}
# Run the disk cleanup tool with the specified flags
Start-Process -FilePath "cleanmgr.exe" -ArgumentList "/sagerun:0"
# Remove the StateFlags0000 registry values that were added
Get-ChildItem -Path $rootKey | ForEach-Object {
if ($_.PSChildName -ne "Offline Pages Files") {
Remove-ItemProperty -Path $_.PSPath -Name "StateFlags0000" -Force
}
}