azure-powershell
azure-powershell copied to clipboard
Recent changes to Connect-AZAccount -DeviceCode cause display issues in the PowerShell ISE
Description
Recent changes to the Connect-AzAaccount cmdlet in the Az.Accounts module cause a display issue when the -DeviceCode switch is used in the PowerShell ISE.
I suspect this is caused by the new display formatting added to the cmdlet.
Example in ISE:
The device code presented is still valid, however it is bracketed by "[4m" on the starting side of the device code, and "[0m" on the ending side of the device code.
Given the lack of PS v7 support in the ISE this may not be surprising, but figured it should be documented in case other folks stuck on legacy scripting tools run into the issue. The issue does not appear when using the same cmd in the PowerShell v5.1 console, only in the ISE itself.
Issue script & Debug output
PS C:\Users\USERNAME> Connect-AzAccount -DeviceCode
DEBUG: 5:55:04 PM - ConnectAzureRmAccountCommand begin processing with ParameterSet 'UserWithSubscriptionId'.
DEBUG: 5:55:04 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:55:04 PM - [ConfigManager] Got nothing from [DefaultSubscriptionForLogin], Module = [], Cmdlet = []. Returning default value [].
DEBUG: 5:55:04 PM - Autosave setting from startup session: 'CurrentUser'
DEBUG: 5:55:04 PM - No autosave setting detected in environment variable 'AzContextAutoSave'.
DEBUG: 5:55:04 PM - Using Autosave scope 'CurrentUser'
DEBUG: 5:55:04 PM - [DeviceCodeAuthenticator] Calling DeviceCodeCredential.AuthenticateAsync - TenantId:'', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/'
DEBUG: DeviceCodeCredential.Authenticate invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET Framework 4.8.9181.0 Microsoft Windows 10.0.22631 [2024-03-30 00:55:04Z - 5dd8649d-0490-4452-a98c-ab89a316b8c7] MSAL MSAL.CoreCLR with assembly version '4.56.0.0'. CorrelationId(5dd8649d-0490-4452-a98c-ab89a316b8
c7)
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET Framework 4.8.9181.0 Microsoft Windows 10.0.22631 [2024-03-30 00:55:04Z - 5dd8649d-0490-4452-a98c-ab89a316b8c7]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenByDeviceCode
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 5dd8649d-0490-4452-a98c-ab89a316b8c7
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET Framework 4.8.9181.0 Microsoft Windows 10.0.22631 [2024-03-30 00:55:04Z - 5dd8649d-0490-4452-a98c-ab89a316b8c7] === Token Acquisition (DeviceCodeRequest) started:
Scopes: https://management.core.windows.net//.default
Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET Framework 4.8.9181.0 Microsoft Windows 10.0.22631 [2024-03-30 00:55:04Z - 5dd8649d-0490-4452-a98c-ab89a316b8c7] [Instance Discovery] Instance discovery is enabled and will be performed
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET Framework 4.8.9181.0 Microsoft Windows 10.0.22631 [2024-03-30 00:55:04Z - 5dd8649d-0490-4452-a98c-ab89a316b8c7] [Region discovery] Not using a regional authority.
DEBUG: Request [982233ba-d4a4-4e50-a10b-0e1535f1baba] POST https://login.microsoftonline.com/organizations/oauth2/v2.0/devicecode
x-client-SKU:REDACTED
x-client-Ver:REDACTED
x-client-CPU:REDACTED
x-client-OS:REDACTED
client-request-id:REDACTED
return-client-request-id:REDACTED
x-app-name:REDACTED
x-app-ver:REDACTED
Content-Type:application/x-www-form-urlencoded
x-ms-client-request-id:982233ba-d4a4-4e50-a10b-0e1535f1baba
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Identity/1.10.3 (.NET Framework 4.8.9181.0; Microsoft Windows 10.0.22631 )
client assembly: Azure.Identity
DEBUG: Response [982233ba-d4a4-4e50-a10b-0e1535f1baba] 200 OK (00.3s)
Pragma:no-cache
Strict-Transport-Security:REDACTED
X-Content-Type-Options:REDACTED
client-request-id:REDACTED
x-ms-request-id:ad938475-364f-42d0-a5f2-e690bbf9a000
x-ms-ests-server:REDACTED
x-ms-clitelem:REDACTED
x-ms-srs:REDACTED
X-XSS-Protection:REDACTED
Cache-Control:no-store, no-cache
Content-Type:application/json; charset=utf-8
Expires:-1
P3P:REDACTED
Set-Cookie:REDACTED
Date:Sat, 30 Mar 2024 00:55:04 GMT
Content-Length:473
DEBUG: Request [afa34a69-a115-40d4-95b7-f00fe5212558] POST https://login.microsoftonline.com/organizations/oauth2/v2.0/token
x-client-SKU:REDACTED
x-client-Ver:REDACTED
x-client-CPU:REDACTED
x-client-OS:REDACTED
x-client-current-telemetry:REDACTED
x-client-last-telemetry:REDACTED
x-ms-lib-capability:REDACTED
client-request-id:REDACTED
return-client-request-id:REDACTED
x-app-name:REDACTED
x-app-ver:REDACTED
Content-Type:application/x-www-form-urlencoded
x-ms-client-request-id:afa34a69-a115-40d4-95b7-f00fe5212558
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Identity/1.10.3 (.NET Framework 4.8.9181.0; Microsoft Windows 10.0.22631 )
client assembly: Azure.Identity
[1m[44m[Login to Azure][0m To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code [4mXXXXXXXXX[0m to authenticate.
Environment data
Name Value
---- -----
PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Module versions
get-module az*
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.16.0 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}
Error output
No response
Thanks for reporting. @BethanyZhou let's consider having different behaviors on ps5/7+
Hi @isra-fel , PowerShell ISE is an integrated scripting Environment different with PowerShell 5/7. I'm not sure if we should support this platform as well?
Let's implement a fall back for ISE. We should check if the terminal (on Windows) supports VT and ISE will return false. In PowerShell, it would be: $host.ui.supportsvirtualterminal
Hi There ,
Did this issue get addressed? I know it was reported in March. I had a similar issue today.
Hi we are working on this. @lijinpei2008 please update this thread when we make progress. Thanks.
The issue has been fixed and will be rolled out in a later release.