Skip to content

Update PowerShell script to version 1.3 with enhancements - #2009

Open
Michael Morten Sonne | Microsoft MVP (michaelmsonne) wants to merge 2 commits into
MicrosoftDocs:mainfrom
michaelmsonne:patch-9
Open

Update PowerShell script to version 1.3 with enhancements#2009
Michael Morten Sonne | Microsoft MVP (michaelmsonne) wants to merge 2 commits into
MicrosoftDocs:mainfrom
michaelmsonne:patch-9

Conversation

@michaelmsonne

Copy link
Copy Markdown
Contributor

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: #2005 where this should be included ref. Ken Withee (@kenwith)

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
@prmerger-automator

Copy link
Copy Markdown
Contributor

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-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 2e783a2:

✅ Validation status: passed

File Status Preview URL Details
docs/global-secure-access/scripts/powershell-get-token.md ✅Succeeded

For more details, please refer to the build report.

@prmerger-automator

Copy link
Copy Markdown
Contributor

PRMerger Results

Issue Description
File Change Percent This PR contains file(s) with more than 30% file change.

@v-regandowner

Copy link
Copy Markdown
Contributor

Ken Withee (@kenwith)

Can you review the proposed changes?

IMPORTANT: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 #Requires directives, strict mode, and try/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.
Comment on lines +34 to +36
# 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
Comment on lines +72 to +74
# Start transcript for logging
$transcriptPath = Join-Path $env:TEMP "EntraConnectorToken_$(Get-Date -Format 'yyyyMMdd_HHmmss').log"
Start-Transcript -Path $transcriptPath -Append
Comment on lines +382 to 385
finally {
Stop-Transcript
Write-Host "Log file saved to: $transcriptPath" -ForegroundColor Cyan
}
Comment thread docs/global-secure-access/scripts/powershell-get-token.md Outdated
Comment thread docs/global-secure-access/scripts/powershell-get-token.md
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 88a776c:

✅ Validation status: passed

File Status Preview URL Details
docs/global-secure-access/scripts/powershell-get-token.md ✅Succeeded

For more details, please refer to the build report.

@prmerger-automator

Copy link
Copy Markdown
Contributor

PRMerger Results

Issue Description
File Change Percent This PR contains file(s) with more than 30% file change.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants