Skip to content

Update sac-enabler.ps1 to v1.3#126

Open
anmocanu wants to merge 4 commits into
Azure:mainfrom
anmocanu:patch-6
Open

Update sac-enabler.ps1 to v1.3#126
anmocanu wants to merge 4 commits into
Azure:mainfrom
anmocanu:patch-6

Conversation

@anmocanu

Copy link
Copy Markdown
Contributor

This script enables Special Administration Console (SAC) and Serial Console boot settings on an attached OS disk's BCD store. It includes enhanced logic for Gen2 disks and improved error handling.
.VERSION
v1.3: [May 2026] - Updated the script again (current)
- Fixed breaking exception when the Hyper-V module is not installed on the host.
- Added explicit checking via Get-Module before executing nested VM discovery.
v1.2: [May 2026] - Updated the script
- Included advanced Gen2 unlettered EFI fallback and dynamic drive-letter assignment.
v0.1: Initial commit. This was the version 1.0 of the script

This script enables Special Administration Console (SAC) and Serial Console boot settings on an attached OS disk's BCD store. It includes enhanced logic for Gen2 disks and improved error handling.
    .VERSION
    v1.3: [May 2026] - Updated the script again (current)
                       - Fixed breaking exception when the Hyper-V module is not installed on the host.
                       - Added explicit checking via Get-Module before executing nested VM discovery.
    v1.2: [May 2026] - Updated the script
                       - Included advanced Gen2 unlettered EFI fallback and dynamic drive-letter assignment.
    v0.1: Initial commit. This was the version 1.0 of the script
@EdwinBernal1
EdwinBernal1 self-requested a review June 16, 2026 13:58
@EdwinBernal1

EdwinBernal1 commented Jun 16, 2026

Copy link
Copy Markdown
Member

Issues Found

🟡 Potential compatibility gap: only checks winload.exe for OS detection

The script sets $isOsPath via \windows\system32\winload.exe only. Some UEFI-oriented scenarios rely on winload.efi path detection. If winload.exe is absent or not suitable in edge images, OS detection may fail even if the disk is valid.

Recommendation: mirror the pattern used in PR #130 and check both winload.exe and winload.efi.

🟢 Minor: fallback failure path could be clearer

If no default boot entry is parsed from displayorder, the script exits with generic failure state. Add explicit warning when $defaultLine/GUID extraction fails for easier troubleshooting.

anmocanu added 3 commits July 9, 2026 10:59
Updated script to enable SAC and Serial Console boot settings on attached Windows disks, improving OS detection and error handling.
Updated the script to improve logging and error handling, including better management of temporary EFI drive letters and enhanced status tracking.
@EdwinBernal1

Copy link
Copy Markdown
Member

@anmocanu could you help us with the review of these findings

Findings

Critical

File Context Issue Recommendation
None

Warning

File Context Issue Recommendation
sac-enabler.ps1 temp EFI letter diskpart assigns a temporary drive letter to the EFI partition. Cleanup is in finally (good), but a hard process kill between assign and cleanup could leave an orphaned mount on the rescue host. Acceptable; the finally guard is the right mitigation. Optionally add a startup sweep for stale temp letters.
sac-enabler.ps1 logging Desktop-only log, not the plugin dir auto-collected by az vm repair run. Dual-write for auto-collection (batch-level).
sac-enabler.ps1 Log-* wrapper Duplicated logging-wrapper pattern (see batch note). Extract shared helper.

Info

File Context Suggestion
sac-enabler.ps1 v2 helper + EFI Because Get-Disk-Partitions-v2 does not letter EFI partitions, the added diskpart logic is the correct compensation. Good Gen1+Gen2 coverage.
sac-enabler.ps1 paired diskpart assign/remove letter operations are paired across try/finally — good registry/partition hygiene.

Operational Risk Assessment

Factor Rating Notes
Scope Low-Medium Single script; adds diskpart partition manipulation.
Destructive ops Low BCD /set edits are reversible via bcdedit; temp letter add/remove only; no file/registry deletion.
Rollback possible Yes SAC/EMS settings can be reverted with bcdedit; .VERIFICATION documents checks.
Testing documented Yes (guide) .SCENARIO_RECREATION/.VERIFICATION provide a repro/validation path.
Gen compatibility Gen1+Gen2 Explicit Gen2 unlettered-EFI handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants