1

I am trying to run a powershell command - ConnectAzureAD and getting the below error-

'Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.7.16602, Culture=neutral,. Could not find or load a specific file.'

This was working earlier with Powershell 5 but not with powershell core.The versions that i am using are as: Powershell - 7.0.1 Az.Accounts - 1.8.1 (i have tried updating this but no luck) AzureAd - 2.0.2.104

Is there any workaroudn for this ? We tried Azure.Standard.Preview from 'Post test Gallery' but it failed the keyVault powershell commands. Any help on this?

2
  • 1
    According to the github issue, github.com/Azure/azure-powershell/issues/11446 this is a known limitation and there is no workaround for this. Commented Jul 1, 2020 at 21:11
  • still getting same error..howver i have found a workaround without using Connect-AzureAd which solved my problem for now Commented Sep 25, 2020 at 4:11

3 Answers 3

3
Install-Module -Name AzureADPreview -RequiredVersion 2.0.2.89 
Import-Module AzureADPreview -Version 2.0.2.89 -UseWindowsPowerShell
Sign up to request clarification or add additional context in comments.

1 Comment

Hi and welcome to Stack Overflow! Please take the tour. Thanks for contributing an answer but can you also add an explanation on how it solves the problem?
0

As Shiva said, this is a known limitation on .NET CORE that new version assembly cannot be loaded if old version is already loaded. PowerShell is considering module isolation but so far there is no good solution yet.

You can upgrade Microsoft.IdentityModel.Clients.ActiveDirectory to the latest version.

For more details, you could refer to this issue.

1 Comment

Please let us know if this answer was helpful to you. If so, please remember to mark it as the answer using the check mark so that others in the community with similar questions can more easily find a solution. Also, Please spare few mins to let us know how we did using this link <microsoft.qualtrics.com/jfe/form/… >
0

You could instead try to use the az rest invoking the graph api.

Until the time az-cli is in par with the AzureAD powershell module you can instead use the graph api

az login --tenant <tenantname.onmicrosoft.com>
$uri = "https://graph.microsoft.com/v1.0/applications"

$allApplications = az rest `
   --method GET `
   --uri $uri `
   --headers 'Content-Type=application/json' | convertfrom-json

$allApplications.value |% {"{0}-{1}" -f $_.appid, $_.displayname}

I have put some samples using az rest here, https://github.com/joepaulk/utilities/blob/master/manage-azuread-applicationregistrations.ps1

You may also refer to: https://damienbod.com/2020/06/22/using-azure-cli-to-create-azure-app-registrations/ from where i picked up inspiration

Other reference, how az rest use the accesstokens from az cli can be found here, https://mikhail.io/2019/07/how-azure-cli-manages-access-tokens/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.