Azure / Azure/azure-powershell
AzAD cmdlets ignore -DefaultProfile parameter
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
AzAD cmdlets (ie. Get-AzADUser) only use the currently set context and ignore -DefaultProfile parameter.
We do a lot of parallel work on different threads against different tenants and subscriptions, which means we can't use Set-AzContext because it updates the context on all threads. This means it is currently impossible for us to use AzAD cmdlets in our automation.
### Issue script & Debug output
```PowerShell
PS C:\Users\kwill> Get-AzADUser -First 2 -DefaultProfile $ctxFDPO
PS C:\Users\kwill> Get-AzADUser -First 2 -DefaultProfile $ctxTarget
$ctxFDPO and $ctxTarget are PSAzureContext objects for 2 different tenants. The above commands output the same users, using whatever tenant is currently set by Set-AzContext.
```
### Environment data
```PowerShell
Name Value
---- -----
PSVersion 5.1.22621.963
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.963
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```
### Module versions
```PowerShell
PS C:\Users\kwill> get-module az*
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.12.1 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}
Script 4.9.2 Az.KeyVault {Add-AzKeyVaultCertificate, Add-AzKeyVaultCertificateContact, Add-AzKeyVaultKey, Add-AzKeyVaultManagedStorageAccount...}
Script 6.5.3 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment...}
```
### Error output
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.