Skip to content
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

Import-Module Az.Accounts fails with "Access to the path 'Global\AzurePowerShellConfigInit' is denied" when used concurrent #26907

Open
zeilemaker54 opened this issue Dec 19, 2024 · 1 comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported needs-triage This is a new issue that needs to be triaged to the appropriate team.

Comments

@zeilemaker54
Copy link

zeilemaker54 commented Dec 19, 2024

Description

This is how to ‘build’ an environment to reproduce the issue on a windows computer:

  1. Create 4 local accounts with no additional permissions

  2. Create a folder for powershell scripts

  3. Create a powershell script called test-azaccounts.ps1 with the following content:
    . "$PSScriptRoot\test-azaccounts2.ps1" *>> "$home\Documents\test-azaccounts.log"

  4. Create a powershell script called test-azaccounts2.ps1 with the following content:

$ErrorActionPreference = 'Stop'
$InformationPreference = 'Continue'
$DebugPreference = 'Continue'

Write-Information "$(Get-Date) Start"

try {
  $null = Import-Module Az.Accounts
}
catch {
  Write-Information "$(Get-Date) Error: $($_.Exception.Message)"
}
Write-Information "$(Get-Date) End"

  1. Create a scheduled task for each local account (running as the local account) with the same trigger/schedule running script test-azaccount.ps1 (run powershell.exe with arguments: -noninteractive -file \test-azaccounts.ps1)
    The script will create a logfile in the document folder of each local account.
    You will notice that only 1 scheduled task will succeed, the other 3 will fail.

Issue script & Debug output

See description

Environment data

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

Module versions

On 1 of the instances:
Script     3.0.3                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzConte…

On the other instances:

Error output

On 1 of the instances the following is logged:

12/19/2024 13:30:02 Start
Initializing ConditionalAssemblyContext. PSEdition is [Core]. PSVersion is [7.4.6].
Initializing ConditionalAssemblyProvider. AssemblyRootPath is [C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\3.0.3\StartupScripts\..\lib].
Registering Az shared AssemblyLoadContext.
AssemblyLoadContext registered.
12/19/2024 13:30:04 End

On the other instances:
12/19/2024 13:30:02 Start
Initializing ConditionalAssemblyContext. PSEdition is [Core]. PSVersion is [7.4.6].
Initializing ConditionalAssemblyProvider. AssemblyRootPath is [C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\3.0.3\StartupScripts\..\lib].
Registering Az shared AssemblyLoadContext.
AssemblyLoadContext registered.
12/19/2024 13:30:04 Error: Access to the path 'Global\AzurePowerShellConfigInit' is denied.
12/19/2024 13:30:04 End
@zeilemaker54 zeilemaker54 added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Dec 19, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported needs-triage This is a new issue that needs to be triaged to the appropriate team. and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Dec 19, 2024
@lzandman
Copy link

This looks very similar to this issue I reported: microsoft/azure-pipelines-tasks#20245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported needs-triage This is a new issue that needs to be triaged to the appropriate team.
Projects
None yet
Development

No branches or pull requests

2 participants