Skip to content

[Identity] Update AzurePowerShellCredential script#41675

Merged
pvaneck merged 3 commits intoAzure:mainfrom
pvaneck:update-powershell-cred
Jun 25, 2025
Merged

[Identity] Update AzurePowerShellCredential script#41675
pvaneck merged 3 commits intoAzure:mainfrom
pvaneck:update-powershell-cred

Conversation

@pvaneck
Copy link
Member

@pvaneck pvaneck commented Jun 19, 2025

Closes: #41508

- Only add the `-AsSecureString` argument when available and needed.
  This argument is no longer needed for `Az.Accounts` versions 5.0.0 and
  above.
- Update secure string parsing logic to allow it to work if a user is
  using Windows PowerShell instead of PowerShell 7+.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck pvaneck force-pushed the update-powershell-cred branch from bca9b0c to 83c8f09 Compare June 19, 2025 23:26
@pvaneck pvaneck marked this pull request as ready for review June 20, 2025 20:20
Copilot AI review requested due to automatic review settings June 20, 2025 20:20
@pvaneck pvaneck requested review from a team and xiangyan99 as code owners June 20, 2025 20:20
Copy link
Contributor

Copilot AI left a comment

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 refines the AzurePowerShellCredential helper by restricting the -AsSecureString flag to Az.Accounts versions 2.17.0–<5.0.0 and adds a fallback path for parsing SecureString tokens on Windows PowerShell (<7). It also updates the changelog to document this bug fix.

  • Limit -AsSecureString usage to the intended Az.Accounts version range.
  • Introduce SecureString-to-plaintext conversion logic for PSVersion < 7.
  • Add a changelog entry for the Windows PowerShell compatibility fix.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
sdk/identity/azure-identity/azure/identity/_credentials/azure_powershell.py Adjusted version condition and added branch for SecureString parsing
sdk/identity/azure-identity/CHANGELOG.md Inserted bug fix entry for Windows PowerShell SecureString support
Comments suppressed due to low confidence (2)

sdk/identity/azure-identity/azure/identity/_credentials/azure_powershell.py:51

  • This new branch for Windows PowerShell (<7) parsing logic should be covered by automated tests to ensure both PS 7+ and Windows PowerShell behaviors are validated.
    if ($PSVersionTable.PSVersion.Major -lt 7) {{

sdk/identity/azure-identity/CHANGELOG.md:11

  • Please confirm that #41675 matches this PR number, and consider also linking the original issue (#41508) in the changelog entry for clearer tracking.
- Fixed an issue with `AzurePowerShellCredential` not working correctly for users still using older versions of PowerShell (e.g., Windows PowerShell 5.1) where `-AsPlainText` is not supported in the `ConvertFrom-SecureString` cmdlet.  ([#41675](https://github.com/Azure/azure-sdk-for-python/pull/41675))

…powershell.py

Co-authored-by: Minh-Anh Phan <111523473+minhanh-phan@users.noreply.github.com>
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@github-project-automation github-project-automation bot moved this from Untriaged to In Progress in Azure Identity SDK Improvements Jun 25, 2025
@pvaneck pvaneck merged commit 5b57461 into Azure:main Jun 25, 2025
20 checks passed
@pvaneck pvaneck deleted the update-powershell-cred branch June 25, 2025 21:51
@github-project-automation github-project-automation bot moved this from In Progress to Done in Azure Identity SDK Improvements Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

Update AzurePowerShellCredential for breaking change in Get-AzAccessToken

5 participants