Skip to content

[Identity] Update AzurePowerShellCredential script #41675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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 <[email protected]>
Copy link
Contributor

@Copilot 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

- 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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

Update AzurePowerShellCredential for breaking change in Get-AzAccessToken
3 participants