Skip to content

Connect-AzAccount fails with AADSTS70020. The expiration time of the device code is one hour off. #23557

Open
@mberdev

Description

@mberdev

Description

Short scenario :
Connect-AzAccount fails with error code AADSTS70020.
The error message mentions the trace ID, the correlation ID, the Timestamp.
The timestamp is one hour off my local time. It could be the cause of the failure. Another cause could be the redirections while logging into github.

Long scenario :

  1. Open a Powershell 7.4 terminal on Windows 7.
  2. Run Get-Date. I am in GMT+1 timezone. I get :
> Get-Date
Friday, 24 November 2023 13:41:24
  1. Run Connect-AzAccount
> Connect-AzAccount -DeviceCode
WARNING: To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXXXX to authenticate.

(NOTE: in steps 4 to 6 below, I can't remember if it asks me to log into github FIRST and THEN to enter the device code, or the other way around)

  1. Open a web browser (Chrome). Go to the URL provided : https://microsoft.com/devicelogin Enter the code and validate.
    5a. It asks me to choose an account to log into.
    5b. It takes me to github to log in. I log in
    5c. It asks me to open Microsoft Authenticator on my Android phone for two-factor authentication. I do so.
    5d. I am now logged into github.
    6a. I am now asked to enter the device code
    6b. The device code is accepted on the webpage.
  2. I switch back to the terminal
  3. In the terminal, the connection failed with this error :
WARNING: Unable to acquire token for tenant 'organizations' with error 'DeviceCodeCredential authentication failed: AADSTS70020: The provided value for the input parameter 'device_code' is not valid. This device code has expired. Trace ID: cf766b89-47ca-4a22-9b0a-184b004c9a01 Correlation ID: 9730fd93-7b58-49cc-b958-22913d2e1eac Timestamp: 2023-11-24 12:39:45Z'
Connect-AzAccount: DeviceCodeCredential authentication failed: AADSTS70020: The provided value for the input parameter 'device_code' is not valid. This device code has expired. Trace ID: cf766b89-47ca-4a22-9b0a-184b004c9a01 Correlation ID: 9730fd93-7b58-49cc-b958-22913d2e1eac Timestamp: 2023-11-24 12:42:45Z

I notice that the time in the error message is exactly one hour too early compared to my local time.

Troubleshooting

  1. I run steps 1 to 8 again. This time I don't need to log into github (already logged)
  2. Success! This time the azure login workd.

Account SubscriptionName TenantId Environment


XXXXX Azure subscription 1 XXXXXXXXXX AzureCloud

Issue script & Debug output

It worked the second time so I could not reproduce with $DebugPreference='Continue'

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.13.2                Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzConte

Error output

HistoryId: 20

Message        : DeviceCodeCredential authentication failed: AADSTS70020: The provided value for the input parameter
                 'device_code' is not valid. This device code has expired. Trace ID:
                 cf766b89-47ca-4a22-9b0a-184b004c9a01 Correlation ID: 9730fd93-7b58-49cc-b958-22913d2e1eac Timestamp:
                 2023-11-24 12:39:45Z
StackTrace     :    at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex, String additionalMessage)
                    at Azure.Identity.DeviceCodeCredential.AuthenticateImplAsync(Boolean async, TokenRequestContext
                 requestContext, CancellationToken cancellationToken)
                    at Azure.Identity.DeviceCodeCredential.AuthenticateAsync(TokenRequestContext requestContext,
                 CancellationToken cancellationToken)
                    at Microsoft.Azure.PowerShell.Authenticators.MsalAccessToken.GetAccessTokenAsync(Task`1 authTask,
                 TokenCredential tokenCredential, TokenRequestContext requestContext, CancellationToken
                 cancellationToken)
                    at Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.Authenticate(IAzure
                 Account account, IAzureEnvironment environment, String tenant, SecureString password, String
                 promptBehavior, Action`1 promptAction, IAzureTokenCache tokenCache, String resourceId)
                    at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.AcquireAccessToken(IAzureAccount
                 account, IAzureEnvironment environment, String tenantId, SecureString password, String promptBehavior,
                 Action`1 promptAction, String resourceId)
                    at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.ListAccountTenants(IAzureAccount
                 account, IAzureEnvironment environment, SecureString password, String promptBehavior, Action`1
                 promptAction)
                    at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.Login(IAzureAccount account,
                 IAzureEnvironment environment, String tenantIdOrName, String subscriptionId, String subscriptionName,
                 SecureString password, Boolean skipValidation, IOpenIDConfiguration openIDConfigDoc, Action`1
                 promptAction, String name, Boolean shouldPopulateContextList, Int32 maxContextPopulation, String
                 authScope)
                    at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass127_2.<ExecuteCmdle
                 t>b__5()
                    at System.Threading.Tasks.Task`1.InnerInvoke()
                    at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread,
                 ExecutionContext executionContext, ContextCallback callback, Object state)
                 --- End of stack trace from previous location ---
                    at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread,
                 ExecutionContext executionContext, ContextCallback callback, Object state)
                    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
                 --- End of stack trace from previous location ---
                    at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass127_1.<ExecuteCmdle
                 t>b__1(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
                    at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass136_0.<SetContextWi
                 thOverwritePrompt>b__0(AzureRmProfile prof, RMProfileClient client)
                    at Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2
                 contextAction)
                    at
                 Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3
                 setContextAction)
                    at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOr
                 AsJob>b__3_0(T c)
                    at
                 Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T
                 cmdlet, Action`1 executor)
                    at
                 Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T
                 cmdlet)
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : Azure.Identity.AuthenticationFailedException
InvocationInfo : {Connect-AzAccount}
Line           : Connect-AzAccount -DeviceCode
Position       : At line:1 char:1
                 + Connect-AzAccount -DeviceCode
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 20

Message        : AADSTS70020: The provided value for the input parameter 'device_code' is not valid. This device code
                 has expired. Trace ID: cf766b89-47ca-4a22-9b0a-184b004c9a01 Correlation ID:
                 9730fd93-7b58-49cc-b958-22913d2e1eac Timestamp: 2023-11-24 12:39:45Z
StackTrace     :    at Microsoft.Identity.Client.OAuth2.OAuth2Client.ThrowServerException(HttpResponse response,
                 RequestContext requestContext)
                    at Microsoft.Identity.Client.OAuth2.OAuth2Client.CreateResponse[T](HttpResponse response,
                 RequestContext requestContext)
                    at Microsoft.Identity.Client.OAuth2.OAuth2Client.ExecuteRequestAsync[T](Uri endPoint, HttpMethod
                 method, RequestContext requestContext, Boolean expectErrorsOn200OK, Boolean addCommonHeaders, Func`2
                 onBeforePostRequestData)
                    at Microsoft.Identity.Client.OAuth2.OAuth2Client.GetTokenAsync(Uri endPoint, RequestContext
                 requestContext, Boolean addCommonHeaders, Func`2 onBeforePostRequestHandler)
                    at Microsoft.Identity.Client.OAuth2.TokenClient.SendHttpAndClearTelemetryAsync(String tokenEndpoint,
                 ILoggerAdapter logger)
                    at Microsoft.Identity.Client.OAuth2.TokenClient.SendHttpAndClearTelemetryAsync(String tokenEndpoint,
                 ILoggerAdapter logger)
                    at Microsoft.Identity.Client.OAuth2.TokenClient.SendTokenRequestAsync(IDictionary`2
                 additionalBodyParameters, String scopeOverride, String tokenEndpointOverride, CancellationToken
                 cancellationToken)
                    at Microsoft.Identity.Client.Internal.Requests.DeviceCodeRequest.WaitForTokenResponseAsync(DeviceCode
                 Result deviceCodeResult, CancellationToken cancellationToken)
                    at Microsoft.Identity.Client.Internal.Requests.DeviceCodeRequest.WaitForTokenResponseAsync(DeviceCode
                 Result deviceCodeResult, CancellationToken cancellationToken)
                    at Microsoft.Identity.Client.Internal.Requests.DeviceCodeRequest.ExecuteAsync(CancellationToken
                 cancellationToken)
                    at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken
                 cancellationToken)
                    at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.ExecuteAsync(AcquireTokenCommon
                 Parameters commonParameters, AcquireTokenWithDeviceCodeParameters deviceCodeParameters,
                 CancellationToken cancellationToken)
                    at Azure.Identity.AbstractAcquireTokenParameterBuilderExtensions.ExecuteAsync[T](AbstractAcquireToken
                 ParameterBuilder`1 builder, Boolean async, CancellationToken cancellationToken)
                    at Azure.Identity.MsalPublicClient.AcquireTokenWithDeviceCodeCoreAsync(String[] scopes, String
                 claims, Func`2 deviceCodeCallback, Boolean async, CancellationToken cancellationToken)
                    at Azure.Identity.MsalPublicClient.AcquireTokenWithDeviceCodeAsync(String[] scopes, String claims,
                 Func`2 deviceCodeCallback, Boolean async, CancellationToken cancellationToken)
                    at Azure.Identity.DeviceCodeCredential.GetTokenViaDeviceCodeAsync(TokenRequestContext context,
                 Boolean async, CancellationToken cancellationToken)
                    at Azure.Identity.DeviceCodeCredential.AuthenticateImplAsync(Boolean async, TokenRequestContext
                 requestContext, CancellationToken cancellationToken)
Exception      : Microsoft.Identity.Client.MsalServiceException
InvocationInfo : {Connect-AzAccount}
Line           : Connect-AzAccount -DeviceCode
Position       : At line:1 char:1
                 + Connect-AzAccount -DeviceCode
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 20


   HistoryId: 19

Message        : SharedTokenCacheCredential authentication failed: AADSTS9002332: Application
                 '797f4846-ba00-4fd7-ba43-dac1f8f63013'(Windows Azure Service Management API) is configured for use by
                 Azure Active Directory users only. Please do not use the /consumers endpoint to serve this request.
                 Trace ID: 77cef083-1c64-40d2-a566-7a54e29e6404 Correlation ID: aa50f42c-b57e-43c1-b3eb-fab6ad9af0db
                 Timestamp: 2023-11-24 12:39:21Z
StackTrace     :    at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex, String additionalMessage)
                    at Azure.Identity.SharedTokenCacheCredential.GetTokenImplAsync(Boolean async, TokenRequestContext
                 requestContext, CancellationToken cancellationToken)
                    at Azure.Identity.SharedTokenCacheCredential.GetTokenAsync(TokenRequestContext requestContext,
                 CancellationToken cancellationToken)
                    at Microsoft.Azure.PowerShell.Authenticators.MsalAccessToken.GetAccessTokenAsync(String
                 callerClassName, String parametersLog, TokenCredential tokenCredential, TokenRequestContext
                 requestContext, CancellationToken cancellationToken, String tenantId, String userId, String
                 homeAccountId)
                    at Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.Authenticate(IAzure
                 Account account, IAzureEnvironment environment, String tenant, SecureString password, String
                 promptBehavior, Action`1 promptAction, IAzureTokenCache tokenCache, String resourceId)
                    at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.AcquireAccessToken(IAzureAccount
                 account, IAzureEnvironment environment, String tenantId, SecureString password, String promptBehavior,
                 Action`1 promptAction, String resourceId)
                    at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.ListAccountTenants(IAzureAccount
                 account, IAzureEnvironment environment, SecureString password, String promptBehavior, Action`1
                 promptAction)
                    at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.ListTenants(String tenant)
                    at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.ListSubscriptions(String
                 tenantIdOrDomain)
                    at Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient.Login(IAzureAccount account,
                 IAzureEnvironment environment, String tenantIdOrName, String subscriptionId, String subscriptionName,
                 SecureString password, Boolean skipValidation, IOpenIDConfiguration openIDConfigDoc, Action`1
                 promptAction, String name, Boolean shouldPopulateContextList, Int32 maxContextPopulation, String
                 authScope)
                    at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass127_2.<ExecuteCmdle
                 t>b__5()
                    at System.Threading.Tasks.Task`1.InnerInvoke()
                    at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread,
                 ExecutionContext executionContext, ContextCallback callback, Object state)
                 --- End of stack trace from previous location ---
                    at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread,
                 ExecutionContext executionContext, ContextCallback callback, Object state)
                    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
                 --- End of stack trace from previous location ---
                    at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass127_1.<ExecuteCmdle
                 t>b__1(AzureRmProfile localProfile, RMProfileClient profileClient, String name)
                    at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.<>c__DisplayClass136_0.<SetContextWi
                 thOverwritePrompt>b__0(AzureRmProfile prof, RMProfileClient client)
                    at Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet.ModifyContext(Action`2
                 contextAction)
                    at
                 Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action`3
                 setContextAction)
                    at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOr
                 AsJob>b__3_0(T c)
                    at
                 Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T
                 cmdlet, Action`1 executor)
                    at
                 Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T
                 cmdlet)
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : Azure.Identity.AuthenticationFailedException
InvocationInfo : {Connect-AzAccount}
Line           : Connect-AzAccount
Position       : At line:1 char:1
                 + Connect-AzAccount
                 + ~~~~~~~~~~~~~~~~~
HistoryId      : 19

Message        : AADSTS9002332: Application '797f4846-ba00-4fd7-ba43-dac1f8f63013'(Windows Azure Service Management API)
                 is configured for use by Azure Active Directory users only. Please do not use the /consumers endpoint
                 to serve this request. Trace ID: 77cef083-1c64-40d2-a566-7a54e29e6404 Correlation ID:
                 aa50f42c-b57e-43c1-b3eb-fab6ad9af0db Timestamp: 2023-11-24 12:39:21Z
StackTrace     :    at Microsoft.Identity.Client.OAuth2.OAuth2Client.ThrowServerException(HttpResponse response,
                 RequestContext requestContext)
                    at Microsoft.Identity.Client.OAuth2.OAuth2Client.CreateResponse[T](HttpResponse response,
                 RequestContext requestContext)
                    at Microsoft.Identity.Client.OAuth2.OAuth2Client.ExecuteRequestAsync[T](Uri endPoint, HttpMethod
                 method, RequestContext requestContext, Boolean expectErrorsOn200OK, Boolean addCommonHeaders, Func`2
                 onBeforePostRequestData)
                    at Microsoft.Identity.Client.OAuth2.OAuth2Client.GetTokenAsync(Uri endPoint, RequestContext
                 requestContext, Boolean addCommonHeaders, Func`2 onBeforePostRequestHandler)
                    at Microsoft.Identity.Client.OAuth2.TokenClient.SendHttpAndClearTelemetryAsync(String tokenEndpoint,
                 ILoggerAdapter logger)
                    at Microsoft.Identity.Client.OAuth2.TokenClient.SendHttpAndClearTelemetryAsync(String tokenEndpoint,
                 ILoggerAdapter logger)
                    at Microsoft.Identity.Client.OAuth2.TokenClient.SendTokenRequestAsync(IDictionary`2
                 additionalBodyParameters, String scopeOverride, String tokenEndpointOverride, CancellationToken
                 cancellationToken)
                    at Microsoft.Identity.Client.Internal.SilentRequestHelper.RefreshAccessTokenAsync(MsalRefreshTokenCac
                 heItem msalRefreshTokenItem, RequestBase request, AuthenticationRequestParameters
                 authenticationRequestParameters, CancellationToken cancellationToken)
                    at Microsoft.Identity.Client.Internal.Requests.Silent.CacheSilentStrategy.TryGetTokenUsingFociAsync(C
                 ancellationToken cancellationToken)
                    at Microsoft.Identity.Client.Internal.Requests.Silent.CacheSilentStrategy.RefreshRtOrFailAsync(Cancel
                 lationToken cancellationToken)
                    at
                 Microsoft.Identity.Client.Internal.Requests.Silent.CacheSilentStrategy.ExecuteAsync(CancellationToken
                 cancellationToken)
                    at
                 Microsoft.Identity.Client.Internal.Requests.Silent.CacheSilentStrategy.ExecuteAsync(CancellationToken
                 cancellationToken)
                    at Microsoft.Identity.Client.Internal.Requests.Silent.SilentRequest.ExecuteAsync(CancellationToken
                 cancellationToken)
                    at Microsoft.Identity.Client.Internal.Requests.Silent.SilentRequest.ExecuteAsync(CancellationToken
                 cancellationToken)
                    at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken
                 cancellationToken)
                    at Microsoft.Identity.Client.ApiConfig.Executors.ClientApplicationBaseExecutor.ExecuteAsync(AcquireTo
                 kenCommonParameters commonParameters, AcquireTokenSilentParameters silentParameters, CancellationToken
                 cancellationToken)
                    at Azure.Identity.AbstractAcquireTokenParameterBuilderExtensions.ExecuteAsync[T](AbstractAcquireToken
                 ParameterBuilder`1 builder, Boolean async, CancellationToken cancellationToken)
                    at Azure.Identity.MsalPublicClient.AcquireTokenSilentCoreAsync(String[] scopes, String claims,
                 IAccount account, String tenantId, Boolean async, CancellationToken cancellationToken)
                    at Azure.Identity.MsalPublicClient.AcquireTokenSilentAsync(String[] scopes, String claims, IAccount
                 account, String tenantId, Boolean async, CancellationToken cancellationToken)
                    at Azure.Identity.SharedTokenCacheCredential.GetTokenImplAsync(Boolean async, TokenRequestContext
                 requestContext, CancellationToken cancellationToken)
Exception      : Microsoft.Identity.Client.MsalServiceException
InvocationInfo : {Connect-AzAccount}
Line           : Connect-AzAccount
Position       : At line:1 char:1
                 + Connect-AzAccount
                 + ~~~~~~~~~~~~~~~~~
HistoryId      : 19


   HistoryId: 16

Message        : Cannot validate argument on parameter 'Scope'. The argument "Global" does not belong to the set
                 "CurrentUser,AllUsers" specified by the ValidateSet attribute. Supply an argument that is in the set
                 and then try the command again.
StackTrace     :    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal
                 parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
                    at
                 System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal
                 argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets,
                 CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags
                 flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindNamedParameter(UInt32
                 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter)
                    at System.Management.Automation.ParameterBinderController.BindNamedParameters(UInt32 parameterSets,
                 Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation
                 (Collection`1 arguments)
                    at
                 System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1
                 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                 --- End of stack trace from previous location ---
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput,
                 CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][]
                 commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                 frame)
Exception      : System.Management.Automation.ParameterBindingValidationException
InvocationInfo : {Install-Module}
Line           : Install-Module -Name Az -Scope Global -Repository PSGallery -Allowclobber
Position       : At line:1 char:32
                 + Install-Module -Name Az -Scope Global -Repository PSGallery -Allowclo …
                 +                                ~~~~~~
HistoryId      : 16

Message        : The argument "Global" does not belong to the set "CurrentUser,AllUsers" specified by the ValidateSet
                 attribute. Supply an argument that is in the set and then try the command again.
StackTrace     :    at System.Management.Automation.ValidateSetAttribute.ValidateElement(Object element)
                    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal
                 parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
Exception      : System.Management.Automation.ValidationMetadataException
InvocationInfo : {Install-Module}
Line           : Install-Module -Name Az -Scope Global -Repository PSGallery -Allowclobber
Position       : At line:1 char:32
                 + Install-Module -Name Az -Scope Global -Repository PSGallery -Allowclo …
                 +                                ~~~~~~
HistoryId      : 16


   HistoryId: 15

Message        : No match was found for the specified search criteria and module names 'Az'.
StackTrace     :
Exception      : System.Exception
InvocationInfo : {Uninstall-Package}
Line           :             $null = PackageManagement\Uninstall-Package @PSBoundParameters

Position       : At C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:12733 char:21
                 +$null = PackageManagement\Uninstall-Package @PSBoundParameters
                 +                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 15


   HistoryId: 14

Message        : No match was found for the specified search criteria and module names 'AzureRm'.
StackTrace     :
Exception      : System.Exception
InvocationInfo : {Uninstall-Package}
Line           :             $null = PackageManagement\Uninstall-Package @PSBoundParameters

Position       : At C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:12733 char:21
                 +$null = PackageManagement\Uninstall-Package @PSBoundParameters
                 +                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 14


   HistoryId: 12

Message        : A parameter cannot be found that matches parameter name 'global'.
StackTrace     :    at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBin
                 dingException originalBindingException)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation
                 (Collection`1 arguments)
                    at
                 System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1
                 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                 --- End of stack trace from previous location ---
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput,
                 CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][]
                 commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                 frame)
Exception      : System.Management.Automation.ParameterBindingException
InvocationInfo : {Uninstall-Module}
Line           : Uninstall-Module -Name AzureRm -AllVersions -Force -global
Position       : At line:1 char:52
                 + Uninstall-Module -Name AzureRm -AllVersions -Force -global
                 +                                                    ~~~~~~~
HistoryId      : 12


   HistoryId: 11

Message        : No match was found for the specified search criteria and module names 'AzureRm'.
StackTrace     :
Exception      : System.Exception
InvocationInfo : {Uninstall-Package}
Line           :             $null = PackageManagement\Uninstall-Package @PSBoundParameters

Position       : At C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:12733 char:21
                 +$null = PackageManagement\Uninstall-Package @PSBoundParameters
                 +                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 11


   HistoryId: 10

Message        : No match was found for the specified search criteria and module names 'AzureRm'.
StackTrace     :
Exception      : System.Exception
InvocationInfo : {Uninstall-Package}
Line           :             $null = PackageManagement\Uninstall-Package @PSBoundParameters

Position       : At C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:12733 char:21
                 +$null = PackageManagement\Uninstall-Package @PSBoundParameters
                 +                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 10


   HistoryId: 9

Message        : No match was found for the specified search criteria and module names 'azurerm'.
StackTrace     :
Exception      : System.Exception
InvocationInfo : {Uninstall-Package}
Line           :             $null = PackageManagement\Uninstall-Package @PSBoundParameters

Position       : At C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:12733 char:21
                 +$null = PackageManagement\Uninstall-Package @PSBoundParameters
                 +                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 9


   HistoryId: 8

Message        : Module deletion failed. Please close all PowerShell sessions to ensure no AzureRM modules are currently
                 loaded, and rerun this cmdlet in Administrator mode.
StackTrace     :    at Microsoft.Azure.Commands.Profile.UninstallAzureRm.UninstallAzureRmCommand.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOr
                 AsJob>b__3_0(T c)
                    at
                 Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T
                 cmdlet, Action`1 executor)
                    at
                 Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T
                 cmdlet)
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.UnauthorizedAccessException
InvocationInfo : {Uninstall-AzureRm}
Line           : Uninstall-AzureRm
Position       : At line:1 char:1
                 + Uninstall-AzureRm
                 + ~~~~~~~~~~~~~~~~~
HistoryId      : 8

Message        : Access to the path 'Azure.AnalysisServices.psd1' is denied.
StackTrace     :    at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath, WIN32_FIND_DATA& findData, Boolean
                 topLevel)
                    at System.IO.FileSystem.RemoveDirectory(String fullPath, Boolean recursive)
                    at Microsoft.Azure.Commands.Common.Authentication.Abstractions.DiskDataStore.DeleteDirectory(String
                 dir)
                    at Microsoft.Azure.Commands.Profile.UninstallAzureRm.UninstallAzureRmCommand.ExecuteCmdlet()
Exception      : System.UnauthorizedAccessException
InvocationInfo : {Uninstall-AzureRm}
Line           : Uninstall-AzureRm
Position       : At line:1 char:1
                 + Uninstall-AzureRm
                 + ~~~~~~~~~~~~~~~~~
HistoryId      : 8


   HistoryId: 5

Message        : The term 'az' is not recognized as a name of a cmdlet, function, script file, or executable program.
                 Check the spelling of the name, or if a path was included, verify that the path is correct and try
                 again.
StackTrace     :    at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes
                 commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin,
                 ExecutionContext context)
                    at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe,
                 CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[]
                 redirections, ExecutionContext context)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput,
                 CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][]
                 commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                 frame)
Exception      : System.Management.Automation.CommandNotFoundException
InvocationInfo : {}
Line           :  az
Position       : At line:1 char:2
                 +  az
                 +  ~~
HistoryId      : 5


   HistoryId: 3

Message        : Module 'Az' was not updated because no valid module was found in the module directory. Verify that the
                 module is located in the folder specified by $env:PSModulePath.
StackTrace     :
Exception      : Microsoft.PowerShell.Commands.WriteErrorException
InvocationInfo : {Update-Module}
Line           : Update-Module -Name Az
Position       : At line:1 char:1
                 + Update-Module -Name Az
                 + ~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 3

Message        : No match was found for the specified search criteria and module names 'Az'.
StackTrace     :
Exception      : System.Exception
InvocationInfo : {Get-Package}
Line           :             $installedPackages = PackageManagement\Get-Package @GetPackageParameters

Position       : At C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:13015 char:34
                 + … stalledPackages = PackageManagement\Get-Package @GetPackageParameters
                 +                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 3


   HistoryId: 2

Message        : The following commands are already available on this
                 system:'Login-AzAccount,Logout-AzAccount,Resolve-Error,Send-Feedback'. This module 'Az.Accounts' may
                 override the existing commands. If you still want to install this module 'Az.Accounts', use
                 -AllowClobber parameter.
StackTrace     :
Exception      : System.Exception
InvocationInfo : {Install-Package}
Line           :             $installedPackages = PackageManagement\Install-Package @PSBoundParameters

Position       : At C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9711 char:34
                 + … talledPackages = PackageManagement\Install-Package @PSBoundParameters
                 +                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 2

Metadata

Metadata

Assignees

Labels

AuthenticationAzure PS TeambugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedneeds-team-attentionThis issue needs attention from Azure service team or SDK team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions