scripts/deploy-windows.ps1¶
Platforms: Windows.
Purpose¶
deploy-windows.ps1 is the Windows Blueprint certificate-rotation
wrapper — it is not an application deployment script. It captures the
current Blueprint certificate's public DER, generates a new certificate,
hands both to the transactional rotation logic in
rotate_cert_windows.py, and
only deletes the old certificate from the Windows certificate store after a
smoke test proves the new one works end to end. A -Status flag skips
rotation entirely and delegates to
status-windows.ps1.
Requirements¶
- PowerShell 7+ (
pwsh), not Windows PowerShell 5.1 — the script checks$PSVersionTable.PSVersion.Majoritself (rather than relying on a#Requiresdirective) so it can print an actionable "blue icon vs black icon" message before any PS-7-only syntax runs. - Native Windows (
$IsWindows); the script throws otherwise. - A completed
setup-windows.ps1run: the venv at.venv\Scripts\python.exemust exist, and.envmust containENTRABOT_BLUEPRINT_CERT_SHA1identifying the certificate currently inCert:\CurrentUser\My. - Network access to Microsoft Graph for the
keyCredentialsPATCHand for the post-rotation smoke test's three-hop token acquisition.
Usage¶
# Rotate the Blueprint certificate
.\scripts\deploy-windows.ps1
# Status only — no rotation
.\scripts\deploy-windows.ps1 -Status
.\scripts\deploy-windows.ps1 -Status -Json
.\scripts\deploy-windows.ps1 -Status -HealthOnly -Strict
Options¶
-Status— skip cert rotation and run the consolidated status command viastatus-windows.ps1.-Json— with-Status, output machine-readable JSON.-HealthOnly— with-Status, only print health checks.-Strict— with-Status, return non-zero when health checks fail.-Help— printGet-Help-based documentation and exit0.
Effects¶
- Reads
ENTRABOT_BLUEPRINT_CERT_SHA1from.envto identify the current certificate. - Captures the current certificate's public DER before generating the new
one — for a non-exportable TPM-bound key this is the only chance to
retrieve public material usable for a rollback PATCH. Writes it to a
temporary
.cerfile under%TEMP%. - Calls
generate_windows_cert.pyto generate the new certificate (TPM-first, software-KSP fallback), exporting its public DER to a second temporary.cerfile and capturing its SHA-1 thumbprint andx5t#S256JWT thumbprint from stdout. - Builds a Python driver script inline and runs it under the project venv,
wiring a Graph
PATCHcallable, a smoke-test callable (a freshacquire_agent_user_tokencall), and a certificate-deletion callable torotate_cert_windows.rotate(), which performs the actual transactional rotation:PATCHthe new DER, update.env, smoke-test, then either delete the old certificate (smoke passes) or roll back thePATCH+.env+ MSAL cache (smoke fails). See that page for the full step-by-step rotation and rollback contract. - Deletes the old certificate from
Cert:\CurrentUser\Myonly after the rotation module confirms the smoke test passed. - Does not clean up the temporary old/new
.cerDER files it writes to%TEMP%— they are left on disk after the run, whether it succeeds or fails. - With
-Status, none of the above runs; the script instead invokesstatus-windows.ps1with the forwarded status flags and exits with its exit code.
Exit behavior¶
0— rotation succeeded (new certificate live, old one deleted), or-Helpwas requested.1— launched from Windows PowerShell 5.1 (checked before-Statusand before any rotation logic runs).1— not running on Windows, the venv is missing,.envhas noENTRABOT_BLUEPRINT_CERT_SHA1,generate_windows_cert.pyfailed, or the Python driver raised any ofRotationFailed,RotationRolledBack, orManualInterventionRequired(see the rotation module's exit behavior for what each means and what state each leaves.env/the certificate store in).-Status— exits with whatever code the underlyingstatus-windows.ps1invocation returns.
Common failures¶
This script needs PowerShell 7+— launched from the blue-icon Windows PowerShell 5.1; openpwsh(black icon) and re-run.venv not found— runsetup-windows.ps1first.ENTRABOT_BLUEPRINT_CERT_SHA1 missing from .env— the machine has not completed initial setup, or.envwas hand-edited; re-runsetup-windows.ps1.- Rotation failed with no rollback needed — the initial Graph
PATCHitself failed; the old certificate is untouched and still active. - Rotation rolled back — the new certificate's smoke test failed after
the
PATCHsucceeded; the original certificate,.envthumbprints, and MSAL cache were restored automatically. Re-run once the underlying issue (for example, license replication delay) clears. ManualInterventionRequired— both the initial and rollbackPATCHcalls failed;.envand the MSAL cache are deliberately left as-is for manual triage, since the old DER may be the only public material matching a still-working private key.
Related commands¶
- Script reference — Setup
rotate_cert_windows.py— the transactional rotation and rollback logic this wrapper drives.generate_windows_cert.py— generates the new certificate material.setup-windows.ps1— first-time Windows provisioning that this wrapper assumes has already run.status-windows.ps1— status/health reporting reached via-Status.