Update PowerShell script to version 1.3 with enhancements - #2009
Update PowerShell script to version 1.3 with enhancements#2009Michael Morten Sonne | Microsoft MVP (michaelmsonne) wants to merge 2 commits into
Conversation
Added comprehensive error handling, logging, and user feedback enhancements. Updated script to enforce version requirements and improve cleanup logic. Updated PowerShell script to version 1.3 with comprehensive error handling, logging, and user feedback enhancements. - Added comprehensive error handling with try-catch-finally blocks throughout the script - Added #Requires statements for version validation and administrator rights enforcement - Implemented transcript logging for full execution history and debugging - Added color-coded console output (Green=Success, Yellow=Warning, Red=Error, Cyan=Info) - Enhanced download validation with file size and existence checks - Added exit code checking for installer/uninstaller processes - Improved cleanup logic with array-based folder management - Added automatic cleanup on script failure - Enhanced user feedback with progress indicators and status messages - Added validation for MSAL library existence before loading Implemented strict mode for better error detection - Added error-specific cleanup in catch block to ensure clean state In regards to old: MicrosoftDocs#2005 where this should be included ref. @kenwith
|
Michael Morten Sonne | Microsoft MVP (@michaelmsonne) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change. |
|
Learn Build status updates of commit 2e783a2: ✅ Validation status: passed
For more details, please refer to the build report. |
PRMerger Results
|
|
Can you review the proposed changes? IMPORTANT: When the changes are ready for publication, adding a #label:"aq-pr-triaged" |
There was a problem hiding this comment.
Pull request overview
This PR updates the embedded PowerShell sample in powershell-get-token.md to “version 1.3”, aiming to improve reliability and diagnosability via stricter error handling, transcript logging, clearer user feedback, and more defensive validation around download/install/uninstall steps.
Changes:
- Adds
#Requiresdirectives, strict mode, andtry/catch/finally-style error handling across the script. - Introduces transcript logging plus more structured, color-coded status output.
- Enhances download validation, exit-code checking, and cleanup behavior (including cleanup on failure).
| ## Sample script | ||
|
|
||
| ```powershell | ||
| # This sample script lets you obtain the Auth Token that you can use for registering the Entra private network connector through Marketplace. |
| # CHANGELOG: | ||
| # Version 1.3 (2026-06-17) - Michael Morten Sonne, https://github.com/michaelmsonne | ||
| # - Added comprehensive error handling with try-catch-finally blocks throughout the script |
| # Start transcript for logging | ||
| $transcriptPath = Join-Path $env:TEMP "EntraConnectorToken_$(Get-Date -Format 'yyyyMMdd_HHmmss').log" | ||
| Start-Transcript -Path $transcriptPath -Append |
| finally { | ||
| Stop-Transcript | ||
| Write-Host "Log file saved to: $transcriptPath" -ForegroundColor Cyan | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Learn Build status updates of commit 88a776c: ✅ Validation status: passed
For more details, please refer to the build report. |
PRMerger Results
|
Added comprehensive error handling, logging, and user feedback enhancements. Updated script to enforce version requirements and improve cleanup logic.
Updated PowerShell script to version 1.3 with comprehensive error handling, logging, and user feedback enhancements.
In regards to old: #2005 where this should be included ref. Ken Withee (@kenwith)