Cant load a particular module in Powershell

97 Views Asked by At

I am trying to use [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext] as follows:

$authContext = 
  [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext]$authUrl

I have run:

 Install-Module -Name AzureAD -AllowClobber

then:

 Import-Module -Name AzureAD

But I keep getting the error:

Unable to find type [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext].

Any ideas on how I can fix this ?

Update:

  $authUrl = "https://login.windows.net/${tenantId}"
  $authContext =
   [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext 
]$authUrl
$cred = New-Object 
Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential 
$applicationId,$key
0

There are 0 best solutions below