fixed an issue with the cli args for the scrubber tool

This commit is contained in:
2026-10-14 17:43:32 -04:00
parent b07e132b3c
commit e3fe378b41
3 changed files with 203 additions and 13 deletions
+6 -4
View File
@@ -63,7 +63,7 @@ Validation writes logs and staging files, secures its workspace, and runs ODT ex
The script resolves the current versioned ODT download from the [Microsoft Download Center](https://www.microsoft.com/en-us/download/details.aspx?id=49117). It does not depend on the Emberkom-hosted setup.exe or a frozen Microsoft binary URL. If the page format changes, it stops before removal. The downloaded ODT package and extracted setup.exe must have valid Microsoft signatures.
The [Get Help command-line package](https://learn.microsoft.com/en-us/troubleshoot/microsoft-365/admin/miscellaneous/get-help-command-line-overview) is downloaded fresh and its executable signature checked. Microsoft's evergreen link still uses the historical name `https://aka.ms/SaRA_EnterpriseVersionFiles`. The script executes `GetHelpCmd.exe`, not retired `SaRAcmd.exe`.
The [Get Help command-line package](https://learn.microsoft.com/en-us/troubleshoot/microsoft-365/admin/miscellaneous/get-help-command-line-overview) is downloaded fresh and its executable signature checked. Microsoft's evergreen link still uses the historical name `https://aka.ms/SaRA_EnterpriseVersionFiles`. The script executes `GetHelpCmd.exe`, not retired `SaRAcmd.exe`. During staging (including validation-only runs), it runs only the read-only `-?` usage command to verify the downloaded tool's command syntax; this does not start an uninstall scenario. Usage output is retained in `gethelp-usage.stdout.log` / `.stderr.log`.
ODT downloads the current build in the selected channel first. Installation is pinned to that local build, uses English (`en-us`), enables updates, and uses `Display Level="None"`. The [ODT configuration reference](https://learn.microsoft.com/en-us/microsoft-365-apps/deploy/office-deployment-tool-configuration-options) describes these settings. Existing update policies can subsequently override the chosen channel.
@@ -80,13 +80,15 @@ These follow Microsoft's deployment guidance for [Teams](https://learn.microsoft
New Outlook, and Teams when selected, are provisioned for current and future users; users may need to sign out and back in for registration. OneDrive installs per-machine and handles migration of existing user accounts. App account setup and any tenant policy prompts are separate from the silent installation. The script does not switch the default mail application, force migration from classic Outlook, or configure OneDrive folder backup.
Removal uses [Get Help's OfficeScrubScenario](https://learn.microsoft.com/en-us/troubleshoot/microsoft-365/admin/miscellaneous/get-help-office-uninstall) with `-OfficeVersion All`, plus separate targeted Appx/provisioned-package and Teams/OneDrive uninstall operations. Office 2007 through Microsoft 365/2024 are covered by the documented scrubber options. Corrupt, unsupported, orphaned, or unusually packaged installations may require manual repair; unknown uninstall commands and remaining detected Office products stop the deployment. This is not a guarantee that every historical Office artifact is erased. No automatic reboot or resume task is created.
Removal uses [Get Help's OfficeScrubScenario](https://learn.microsoft.com/en-us/troubleshoot/microsoft-365/admin/miscellaneous/get-help-office-uninstall), plus separate targeted Appx/provisioned-package and Teams/OneDrive uninstall operations. The script adds `-OfficeVersion All` only when the downloaded tool's usage advertises that switch. The Microsoft-signed build inspected on October 14, 2026 (`1.0.0+d28f675`) rejects it despite Microsoft's documentation; that build internally sets `officeVersion=All` when invoked as `GetHelpCmd.exe -S OfficeScrubScenario -AcceptEula`. The documented coverage spans Office 2007 through Microsoft 365/2024, but actual removal still depends on the downloaded tool's implementation and the endpoint's installation state. Corrupt, unsupported, orphaned, or unusually packaged installations may require manual repair; unknown uninstall commands and remaining detected Office products stop the deployment. No automatic reboot or resume task is created.
The script recognizes both the older numbered scenario results and the current `Scenario completed successfully.` message. A process exit of zero alone does not prove success: this Get Help build also returns zero for invalid arguments. Error text is logged and included in the Syncro failure message. When Get Help reports that uninstall is running in the background, the script polls for up to 30 minutes, requiring Office inventory to become empty and newly launched installer/script workers to exit, followed by a 60-second quiet interval. Existing unrelated consoles and idle installer service hosts do not block completion. This avoids immediately reinstalling after a background-launch acknowledgement. A timeout stops installation and reports remaining products/workers; do not launch another deployment over unfinished cleanup.
Transient failures get bounded recovery before deployment stops:
- HTTP downloads, including the ODT discovery page, get three attempts. ODT `/download` also gets three attempts using the same staging folder, before any app removal. An unrecognized discovery page, invalid signature, or invalid staged payload still fails validation.
- Machine and per-user MSI removal retry Windows Installer's [busy result, `1618`](https://learn.microsoft.com/en-us/windows/win32/msi/error-codes), up to five attempts with 15 seconds between attempts. Other installer failure codes retain their existing handling. The script does not kill an unrelated installer or blindly repeat an Office installation or scrub.
- After successful operations, machine removal and installation verification allow up to 60 seconds of polling for registry/package state to settle. The user's Teams add-in removal has the same allowance. Reads that fail still raise an error; inaccessible state is not treated as proof that an app is gone.
- After successful operations, machine removal and installation verification allow up to 60 seconds of polling for registry/package state to settle. The user's Teams add-in removal has the same allowance. Get Help's explicitly asynchronous removal uses the longer background wait described above. Reads that fail still raise an error; inaccessible state is not treated as proof that an app is gone.
- Appx removal checks whether the exact package disappeared even when the removal command reports an error. If it remains, removal retries up to three times, each followed by the verification wait. Installed and provisioned packages must both be absent before continuing.
- A process that exits just before forced shutdown is tolerated. Failure to unregister an already-completed cleanup task is logged and does not stop installation; its completion marker makes subsequent task runs a no-op.
@@ -127,7 +129,7 @@ The installer verifies the selected Office product, bitness, and downloaded vers
## Verification
Run `powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\tests\Install-MicrosoftOffice365.Tests.ps1` for offline checks. They require Windows PowerShell 5.1 and exercise the default validation gate (including `Force`), explicit deployment opt-out, log/console routing with the real Tools helpers, XML, removal-result handling, bounded cache deletion, companion installer failures/verification, deferred cleanup protection, and the unchanged `Run-Script` receiving injected strings through the shim with a mocked workload. Recovery checks simulate busy MSI, delayed registration, transient downloads, Appx removal races, persistent failures, and completed-task housekeeping errors. An inert executable checks actual native argument passing; a 32-bit Windows PowerShell child checks relaunch into 64-bit Windows PowerShell 5.1 and exit-code propagation. They do not run Microsoft installers or clear actual credentials.
Run `powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\tests\Install-MicrosoftOffice365.Tests.ps1` for offline checks. They require Windows PowerShell 5.1 and exercise the default validation gate (including `Force`), explicit deployment opt-out, log/console routing with the real Tools helpers, XML, removal-result handling, bounded cache deletion, companion installer failures/verification, deferred cleanup protection, and the unchanged `Run-Script` receiving injected strings through the shim with a mocked workload. Recovery checks simulate busy MSI, delayed registration, transient downloads, Appx removal races, persistent failures, and completed-task housekeeping errors. Get Help regression cases use captured usage text, both result formats, zero-exit argument errors, and background workers/registration delays/timeouts. An inert executable checks actual native argument passing; a 32-bit Windows PowerShell child checks relaunch into 64-bit Windows PowerShell 5.1 and exit-code propagation. They do not run Microsoft installers or clear actual credentials.
`Run-Script` is unchanged. Its existing local execution can read the Syncro variables from the enclosing caller scope. The Office workload validates those values and reports its own result and exit code. The shim only sets TLS, dot-sources `Tools.ps1`, and invokes the workload. Existing `Run-Script` bootstrap failure behavior also remains unchanged.