microsoftgraph / msgraph-sdk-powershell

Powershell SDK for Microsoft Graph
https://www.powershellgallery.com/packages/Microsoft.Graph
Other
708 stars 169 forks source link

Assembly conflict between Az.Account and Microsoft.Graph.Authentication in PowerShell 5.1 #2148

Closed peterboba closed 1 year ago

peterboba commented 1 year ago

Describe the bug There seems to be an assembly conflict when using Az and Microsoft.Graph 2.0.0 Powershell modules in the same session. This was not a problem with the previous version of Microsoft.Graph Powershell. Brief investigation shows that this might be an issue with incompatible Azure.Identity (or Azure.Core) dll introduced in 2.0.0 version of Microsoft.Graph Powershell.

This is quite an problem for us as we need to use Powershell 5.1 and the mentioned modules together.

It doesn't look like the fix below solves the issue. https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/1880 https://github.com/microsoftgraph/msgraph-sdk-powershell/pull/1894

To Reproduce Steps to reproduce the behavior:

Import-Module Az.Accounts
Import-Module Microsoft.Graph.Authentication
Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.12.4     Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear...
Script     2.0.0      Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, G...
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, En...
Script     2.0.0      PSReadline                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...

Get-MgApplication
Get-MgApplication : Method not found: 'Void
Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[],
Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'.
At line:1 char:1
+ Get-MgApplication
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-MgApplication_List], MissingMethodException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgApplication_List

Expected behavior

Get-MgApplication
Get-MgApplication : Authentication needed. Please call Connect-MgGraph.
At line:1 char:1
+ Get-MgApplication
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-MgApplication_List], AuthenticationException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgApplication_List

Debug Output Bad outcome

Get-MgApplication -Debug
DEBUG: [CmdletBeginProcessing]: - Get-MgApplication begin processing with parameterSet 'List'.

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): Y
DEBUG: [CmdletException]: Received exception with message 'MissingMethodException - Method not found: 'Void
Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[],
Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'. :    at
Microsoft.Graph.PowerShell.Authentication.Core.Utilities.AuthenticationHelpers.<GetAuthenticationProviderAsync>d__10.Mo
veNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at
Microsoft.Graph.PowerShell.Authentication.Core.Utilities.AuthenticationHelpers.GetAuthenticationProviderAsync(IAuthCont
ext authContext)
   at Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers.GetGraphHttpClient()
   at Microsoft.Graph.PowerShell.Module.BeforeCreatePipeline(InvocationInfo invocationInfo, HttpPipeline& pipeline)
   at Microsoft.Graph.PowerShell.Module.CreatePipeline(InvocationInfo invocationInfo, String parameterSetName)
   at Microsoft.Graph.PowerShell.Cmdlets.GetMgApplication_List.<ProcessRecordAsync>d__84.MoveNext()'

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): Y

Confirm
Method not found: 'Void
Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[],
Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'.
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): Y
Get-MgApplication : Method not found: 'Void
Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[],
Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'.
At line:1 char:1
+ Get-MgApplication -Debug
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-MgApplication_List], MissingMethodException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgApplication_List

DEBUG: [CmdletEndProcessing]: - Get-MgApplication end processing.

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): Y

Expected outcome

Get-MgApplication -Debug
DEBUG: [CmdletBeginProcessing]: - Get-MgApplication begin processing with parameterSet 'List'.

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): Y
DEBUG: [CmdletException]: Received exception with message 'AuthenticationException - Authentication needed. Please call
 Connect-MgGraph. :    at
Microsoft.Graph.PowerShell.Authentication.Core.Utilities.AuthenticationHelpers.<GetAuthenticationProviderAsync>d__10.Mo
veNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers.GetGraphHttpClient()
   at Microsoft.Graph.PowerShell.Module.BeforeCreatePipeline(InvocationInfo invocationInfo, HttpPipeline& pipeline)
   at Microsoft.Graph.PowerShell.Module.CreatePipeline(InvocationInfo invocationInfo, String parameterSetName)
   at Microsoft.Graph.PowerShell.Cmdlets.GetMgApplication_List.<ProcessRecordAsync>d__84.MoveNext()'

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): Y

Confirm
Authentication needed. Please call Connect-MgGraph.
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): Y
Get-MgApplication : Authentication needed. Please call Connect-MgGraph.
At line:1 char:1
+ Get-MgApplication -Debug
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-MgApplication_List], AuthenticationException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgApplication_List

DEBUG: [CmdletEndProcessing]: - Get-MgApplication end processing.

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): Y

Module Version

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.0.0      Microsoft.Graph.Applications        {Add-MgApplicationKey, Add-MgApplicationPassword, Add-MgSe...
Script     2.0.0      Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, G...

Environment Data

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.3031
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.3031
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Additional Context

Azure.Core, Version=1.31.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netfx\Azure.Core.dll  False   True    
Azure.Core, Version=1.32.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8  C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Desktop\Azure.Core.dll False   True    
Azure.Identity, Version=1.6.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\Azure.Identity.dll False   True    
Azure.Identity, Version=1.9.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8   C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Azure.Identity.dll False   True    
Azure.Identity.BrokeredAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\Azure.Identity.BrokeredAuthentication.dll  False   True    
FuzzySharp, Version=1.0.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\FuzzySharp.dll    False   True    
Hyak.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Hyak.Common.dll   False   True    
Microsoft.ApplicationInsights, Version=2.13.1.12554, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.ApplicationInsights.dll False   True    
Microsoft.Azure.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.Common.dll    False   True    
Microsoft.Azure.PowerShell.AssemblyLoading, Version=2.12.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.AssemblyLoading.dll    False   True    
Microsoft.Azure.PowerShell.Authentication, Version=2.12.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Authentication.dll False   True    
Microsoft.Azure.PowerShell.Authentication.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Authentication.Abstractions.dll    False   True    
Microsoft.Azure.PowerShell.Authentication.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Authentication.ResourceManager.dll False   True    
Microsoft.Azure.PowerShell.Authenticators, Version=2.12.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Authenticators.dll False   True    
Microsoft.Azure.PowerShell.Clients.Aks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Clients.Aks.dll    False   True    
Microsoft.Azure.PowerShell.Clients.Authorization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Clients.Authorization.dll  False   True    
Microsoft.Azure.PowerShell.Clients.Compute, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Clients.Compute.dll    False   True    
Microsoft.Azure.PowerShell.Clients.Graph.Rbac, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Clients.Graph.Rbac.dll False   True    
Microsoft.Azure.PowerShell.Clients.KeyVault, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Clients.KeyVault.dll   False   True    
Microsoft.Azure.PowerShell.Clients.Monitor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Clients.Monitor.dll    False   True    
Microsoft.Azure.PowerShell.Clients.Network, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Clients.Network.dll    False   True    
Microsoft.Azure.PowerShell.Clients.PolicyInsights, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Clients.PolicyInsights.dll False   True    
Microsoft.Azure.PowerShell.Clients.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Clients.ResourceManager.dll    False   True    
Microsoft.Azure.PowerShell.Clients.Storage.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Clients.Storage.Management.dll False   True    
Microsoft.Azure.PowerShell.Clients.Websites, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Clients.Websites.dll   False   True    
Microsoft.Azure.PowerShell.Cmdlets.Accounts, Version=2.12.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll   False   True    
Microsoft.Azure.PowerShell.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Common.dll False   True    
Microsoft.Azure.PowerShell.Common.Share, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Common.Share.dll   False   True    
Microsoft.Azure.PowerShell.Storage, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Storage.dll    False   True    
Microsoft.Azure.PowerShell.Strategies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Azure.PowerShell.Strategies.dll False   True    
Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\Microsoft.Bcl.AsyncInterfaces.dll  False   True    
Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll True    True    
Microsoft.Graph.Applications.private, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Applications\2.0.0\bin\Microsoft.Graph.Applications.private.dll  False   True    
Microsoft.Graph.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Microsoft.Graph.Authentication.dll  False   True    
Microsoft.Graph.Authentication.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Microsoft.Graph.Authentication.Core.dll False   True    
Microsoft.Graph.Core, Version=3.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Desktop\Microsoft.Graph.Core.dll   False   True    
Microsoft.Identity.Client, Version=4.49.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae   C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Desktop\Microsoft.Identity.Client.dll  False   True    
Microsoft.Identity.Client.Broker, Version=4.49.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\Microsoft.Identity.Client.Broker.dll   False   True    
Microsoft.Identity.Client.Extensions.Msal, Version=2.23.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netfx\Microsoft.Identity.Client.Extensions.Msal.dll   False   True    
Microsoft.Identity.Client.Extensions.Msal, Version=2.25.3.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae   C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Desktop\Microsoft.Identity.Client.Extensions.Msal.dll  False   True    
Microsoft.Identity.Client.NativeInterop, Version=0.13.3.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\Microsoft.Identity.Client.NativeInterop.dll    False   True    
Microsoft.IdentityModel.Abstractions, Version=6.22.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\Microsoft.IdentityModel.Abstractions.dll   False   True    
Microsoft.IdentityModel.Abstractions, Version=6.30.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Microsoft.IdentityModel.Abstractions.dll   False   True    
Microsoft.Kiota.Abstractions, Version=1.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Microsoft.Kiota.Abstractions.dll   False   True    
Microsoft.Kiota.Authentication.Azure, Version=1.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Microsoft.Kiota.Authentication.Azure.dll   False   True    
Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Management.Infrastructure\v4.0_1.0.0.0__31bf3856ad364e35\Microsoft.Management.Infrastructure.dll   True    True    
Microsoft.PowerShell.Commands.Diagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Diagnostics\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Diagnostics.dll   True    True    
Microsoft.PowerShell.Commands.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Management\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Management.dll True    True    
Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Utility\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Utility.dll   True    True    
Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.ConsoleHost\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.ConsoleHost.dll True    True    
Microsoft.PowerShell.GraphicalHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.GraphicalHost\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.GraphicalHost.dll True    True    
Microsoft.Powershell.PSReadline, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  C:\Program Files\WindowsPowerShell\Modules\PSReadline\2.0.0\Microsoft.PowerShell.PSReadLine.dll False   True    
Microsoft.PowerShell.Security, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Security\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Security.dll   True    True    
Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Rest.ClientRuntime.dll  False   True    
Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.Rest.ClientRuntime.Azure.dll    False   True    
Microsoft.WindowsAzure.Storage, Version=9.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.WindowsAzure.Storage.dll    False   True    
Microsoft.WindowsAzure.Storage.DataMovement, Version=0.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\Microsoft.WindowsAzure.Storage.DataMovement.dll   False   True    
Microsoft.WSMan.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35   C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.WSMan.Management\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.WSMan.Management.dll True    True    
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll    True    True    
netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51  C:\Windows\Microsoft.Net\assembly\GAC_MSIL\netstandard\v4.0_2.0.0.0__cc7b13ffcd2ddd51\netstandard.dll   True    True    
Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Desktop\Newtonsoft.Json.dll    False   True    
PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Windows\Microsoft.Net\assembly\GAC_64\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll   True    True    
PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll   True    True    
PresentationFramework.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero2\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero2.dll   True    True    
PresentationFramework.Classic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Classic\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Classic.dll   True    True    
PresentationFramework-SystemCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemCore\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemCore.dll True    True    
PresentationFramework-SystemData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemData\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemData.dll True    True    
PresentationFramework-SystemXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089  C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXml\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXml.dll   True    True    
System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089   C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll True    True    
System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\System.Buffers.dll False   True    
System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a   C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Collections\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Collections.dll True    True    
System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll True    True    
System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration.Install\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.Install.dll True    True    
System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089  C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll   True    True    
System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089  C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll True    True    
System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netfx\System.Diagnostics.DiagnosticSource.dll False   True    
System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51  C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Desktop\System.Diagnostics.DiagnosticSource.dll    False   True    
System.Diagnostics.Tracing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a   C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Diagnostics.Tracing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Diagnostics.Tracing.dll True    True    
System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.DirectoryServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.DirectoryServices.dll True    True    
System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a   C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll True    True    
System.Dynamic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a   C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Dynamic\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Dynamic.dll True    True    
System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a    C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Management\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Management.dll   True    True    
System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll True    True    
System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\System.Memory.dll  False   True    
System.Memory.Data, Version=1.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\System.Memory.Data.dll False   True    
System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a  C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll   True    True    
System.Net.Http.WinHttpHandler, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\System.Net.Http.WinHttpHandler.dll False   True    
System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089  C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll   True    True    
System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netfx\System.Numerics.Vectors.dll False   True    
System.Private.ServiceModel, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\System.Private.ServiceModel.dll    False   True    
System.Reflection.DispatchProxy, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netfx\System.Reflection.DispatchProxy.dll False   True    
System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a   C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll True    True    
System.Runtime.CompilerServices.Unsafe, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netfx\System.Runtime.CompilerServices.Unsafe.dll  False   True    
System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a   C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Desktop\System.Runtime.CompilerServices.Unsafe.dll False   True    
System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a    C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.InteropServices.RuntimeInformation\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.InteropServices.RuntimeInformation.dll   True    True    
System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll True    True    
System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a  C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Security\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Security.dll   True    True    
System.Security.AccessControl, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\System.Security.AccessControl.dll  False   True    
System.Security.Cryptography.Cng, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netfx\System.Security.Cryptography.Cng.dll    False   True    
System.Security.Permissions, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51  C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\System.Security.Permissions.dll    False   True    
System.Security.Principal.Windows, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\System.Security.Principal.Windows.dll  False   True    
System.ServiceModel.Primitives, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a   C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\System.ServiceModel.Primitives.dll False   True    
System.Text.Encodings.Web, Version=4.0.5.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51    C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netfx\System.Text.Encodings.Web.dll   False   True    
System.Text.Encodings.Web, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51    C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\Desktop\System.Text.Encodings.Web.dll  False   True    
System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.12.4\lib\netstandard2.0\System.Text.Json.dll   False   True    
System.Threading, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Threading\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Threading.dll True    True    
System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51    C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\2.0.0\Dependencies\System.Threading.Tasks.Extensions.dll  False   True    
System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089  C:\Windows\Microsoft.Net\assembly\GAC_64\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll True    True    
System.ValueTuple, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51    C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ValueTuple\v4.0_4.0.0.0__cc7b13ffcd2ddd51\System.ValueTuple.dll   True    True    
System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a   C:\Windows\Microsoft.Net\assembly\GAC_64\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll   True    True    
System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll   True    True    
System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll True    True    
System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089  C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll   True    True    
System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089   C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll True    True    
System.Xml.ReaderWriter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a  C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.ReaderWriter\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Xml.ReaderWriter.dll   True    True    
UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\UIAutomationProvider\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationProvider.dll True    True    
UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    C:\Windows\Microsoft.Net\assembly\GAC_MSIL\UIAutomationTypes\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationTypes.dll   True    True    
WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll   True    True    
peterboba commented 1 year ago

Additionally - if the module import order is reversed, Az cmdlets don't work

Import-Module Microsoft.Graph.Authentication
Connect-AzAccount
WARNING: Unable to acquire token for tenant 'organizations' with error 'Method not found:
'System.Threading.Tasks.Task`1<Azure.Identity.AuthenticationRecord>
Azure.Identity.InteractiveBrowserCredential.AuthenticateAsync(Azure.Core.TokenRequestContext,
System.Threading.CancellationToken)'.'
Connect-AzAccount : Method not found: 'System.Threading.Tasks.Task`1<Azure.Identity.AuthenticationRecord>
Azure.Identity.InteractiveBrowserCredential.AuthenticateAsync(Azure.Core.TokenRequestContext,
System.Threading.CancellationToken)'.
At line:1 char:1
+ Connect-AzAccount
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzAccount], MissingMethodException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

Get-MgApplication
Get-MgApplication : Authentication needed. Please call Connect-MgGraph.
At line:1 char:1
+ Get-MgApplication
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-MgApplication_List], AuthenticationException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgApplication_List
peterboba commented 1 year ago

This issue is similar to https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2147

r4hulp commented 1 year ago

This also impacts the Azure DevOps Pipeline agents unfortunately

EUCTechTopics commented 1 year ago

We are impacted by this as well in our pipelines. Haven't found a solution yet..

AlbeAdamit commented 1 year ago

We are also impacted, our script is using the "New-MgGroupOwnerByRef -GroupId $groupId -BodyParameter " command. But it fails because we need to connect to MgGraph first. But when importing the module with "Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" cmd. But for some reason the connect command is skipped and it fails when using the commands later in our scripts.

UPDATE: If you're not using the -UseDeviceAuthentication in your Connect-MgGraph command is not using this flag, it will automatically fallback. It's a feature from the new version.

peombwa commented 1 year ago

Thanks for bringing this to our attention, and sorry for any inconvenience caused in your upgrade from v1.x to v2.x.

Our preliminary investigation points to an assembly conflict with the latest version of Az.Accounts module (v2.12.2+), which unfortunately is a well-known problem with PowerShell 5.1 - https://learn.microsoft.com/en-us/powershell/scripting/dev-cross-plat/resolving-dependency-conflicts.

As workaround, you can consider the following options as we further investigate and try to get to the root cause of the conflict:

r4hulp commented 1 year ago

@peombwa thanks for responding. Do you know if we have a workaround for this issue in AzurePowerShell@5 task?

peombwa commented 1 year ago

thanks for responding. Do you know if we have a workaround for this issue in AzurePowerShell@5 task?

You can try updating AzurePowerShell@5 task to use PowerShell 7 by setting pwsh: true as described at https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-powershell-v5?view=azure-pipelines:

- task: AzurePowerShell@5
  inputs:
    azureSubscription: '$(AZURE_SUBSCRIPTION)'
    azurePowerShellVersion: LatestVersion
    ScriptType: 'InlineScript'
    pwsh: true # Set to true to use PowerShell 7.
    Inline: |
      Connect-MgGraph ...

You can also use azurePowerShellVersion option on the lock the Az SDK version.

peombwa commented 1 year ago

We’ve just shipped v2.1.0, which should address the assembly conflict with the latest versions of Az modules in PowerShell 5.1. Please update to v2.1.0 and let us know if it resolves the issue - https://github.com/microsoftgraph/msgraph-sdk-powershell/releases/tag/2.1.0.

asterictnl-lvdw commented 1 year ago

We’ve just shipped v2.1.0, which should address the assembly conflict with the latest versions of Az modules in PowerShell 5.1. Please update to v2.1.0 and let us know if it resolves the issue - https://github.com/microsoftgraph/msgraph-sdk-powershell/releases/tag/2.1.0.

I have confirmed this is work although with some limitations:

I have not found any other issue yet.

~LvdW

r4hulp commented 1 year ago

We’ve just shipped v2.1.0, which should address the assembly conflict with the latest versions of Az modules in PowerShell 5.1. Please update to v2.1.0 and let us know if it resolves the issue - https://github.com/microsoftgraph/msgraph-sdk-powershell/releases/tag/2.1.0.

I have confirmed this is work although with some limitations:

  • You HAVE to run Connect-AzAccount FIRST now else you will encounter the error that AzureAccount does not work due to dependency issues. This is a bug that should be fixed on Az-powershell-sdk

I have not found any other issue yet.

~LvdW

Thanks for this information. I was having issues with Az and Graph commands even after the update in azurepowershell@5 task. I fixed it by moving to pwsh 7 task instead, but I will give this a go.

ghost commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

jberezanski commented 1 year ago

You can try updating AzurePowerShell@5 task to use PowerShell 7 by setting pwsh: true

For those who cannot immediately upgrade to Mg 2.1.0 and are looking at using Powershell Core in their ADO pipelines instead as a workaround, please be aware of an open problem with the AzurePowerShell@5 task under pwsh 7.3 - Service Connections configured to use client certificate authentication cannot be used, because the task incorrectly passes a file path internally to openssl.exe.

Apart from that issue, I can confirm that Az 9.6.0 and Mg 2.0.0 work in perfect harmony in our pipelines under pwsh.

neilmca-inc commented 1 year ago

I was originally bought here from this issue https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2161

I wasn't too happy with pinning a version to this install IF Powershell 5.x was the issue (as suggested: Install-Module Microsoft.Graph -RequiredVersion 2.1.0 -Force -AllowClobber) so I went down the route of adding pwsh:true to the AzurePowerShell@5 pipeline task - which was an excellent suggestion.

When running on an Azure DevOps hosted pipeline agent using "windows-latest" however, for some reason the Microsoft.Graph module isn't installed for use with PowerShell 7 (like it was with PowerShell 5) so I have to install the module as part of the deployment now - which adds another 20 MINUTES to the runtime whilst it installs it - despite mentions the overall time would be reduced - it's actually increased! https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/134

All this to run a single "Update-MgApplication" in my pipeline - what a price to progress eh?

peterboba commented 1 year ago

We’ve just shipped v2.1.0, which should address the assembly conflict with the latest versions of Az modules in PowerShell 5.1. Please update to v2.1.0 and let us know if it resolves the issue - https://github.com/microsoftgraph/msgraph-sdk-powershell/releases/tag/2.1.0.

I didn't have a chance to reply earlier. Thanks for fixing this! I can confirm that I don't see the same issue with v2.1.0

(with possible limitation)

You HAVE to run Connect-AzAccount FIRST now else you will encounter the error that AzureAccount does not work due to dependency issues. This is a bug that should be fixed on Az-powershell-sdk

fujiant commented 1 year ago

Still having the issue on Windows Powershell 5.1. Get-InstalledModule yields this:

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
10.4.1               Az                                  PSGallery            Microsoft Azure PowerShell - Cmdlets t...
2.13.1               Az.Accounts                         PSGallery            Microsoft Azure PowerShell - Accounts ...
2.0.0                Az.Advisor                          PSGallery            Microsoft Azure PowerShell: Advisor cm...
5.5.1                Az.Aks                              PSGallery            Microsoft Azure PowerShell - Azure man...
1.1.4                Az.AnalysisServices                 PSGallery            Microsoft Azure PowerShell - Analysis ...
4.0.2                Az.ApiManagement                    PSGallery            Microsoft Azure PowerShell - Api Manag...
1.3.0                Az.AppConfiguration                 PSGallery            Microsoft Azure PowerShell: AppConfigu...
2.2.2                Az.ApplicationInsights              PSGallery            Microsoft Azure PowerShell: Applicatio...
1.0.0                Az.ArcResourceBridge                PSGallery            Microsoft Azure PowerShell: ArcResourc...
2.0.0                Az.Attestation                      PSGallery            Microsoft Azure PowerShell - Attestati...
1.0.0                Az.Automanage                       PSGallery            Microsoft Azure PowerShell: Automanage...
1.9.1                Az.Automation                       PSGallery            Microsoft Azure PowerShell - Automatio...
3.5.0                Az.Batch                            PSGallery            Microsoft Azure PowerShell - Batch ser...
2.0.3                Az.Billing                          PSGallery            Microsoft Azure PowerShell - Billing s...
3.1.1                Az.Cdn                              PSGallery            Microsoft Azure PowerShell: Cdn cmdlets
1.2.0                Az.CloudService                     PSGallery            Microsoft Azure PowerShell: CloudServi...
1.14.0               Az.CognitiveServices                PSGallery            Microsoft Azure PowerShell - Cognitive...
6.3.0                Az.Compute                          PSGallery            Microsoft Azure PowerShell - Compute s...
1.0.0                Az.ConfidentialLedger               PSGallery            Microsoft Azure PowerShell: Confidenti...
3.2.2                Az.ContainerInstance                PSGallery            Microsoft Azure PowerShell: ContainerI...
4.1.1                Az.ContainerRegistry                PSGallery            Microsoft Azure PowerShell - Container...
1.12.0               Az.CosmosDB                         PSGallery            Microsoft Azure PowerShell - CosmosDB ...
1.1.0                Az.DataBoxEdge                      PSGallery            Microsoft Azure PowerShell - DataBoxEd...
1.7.0                Az.Databricks                       PSGallery            Microsoft Azure PowerShell: Databricks...
1.17.0               Az.DataFactory                      PSGallery            Microsoft Azure PowerShell - Data Fact...
1.0.3                Az.DataLakeAnalytics                PSGallery            Microsoft Azure PowerShell - Data Lake...
1.3.0                Az.DataLakeStore                    PSGallery            Microsoft Azure PowerShell - Azure Dat...
2.1.0                Az.DataProtection                   PSGallery            Microsoft Azure PowerShell: DataProtec...
1.0.1                Az.DataShare                        PSGallery            Microsoft Azure PowerShell - DataShare...
1.1.0                Az.DeploymentManager                PSGallery            PowerShell .Net Core Microsoft Azure P...
4.0.0                Az.DesktopVirtualization            PSGallery            Microsoft Azure PowerShell: DesktopVir...
1.0.2                Az.DevTestLabs                      PSGallery            Microsoft Azure PowerShell - DevTest L...
1.1.3                Az.Dns                              PSGallery            Microsoft Azure PowerShell - DNS servi...
1.6.0                Az.EventGrid                        PSGallery            Microsoft Azure PowerShell - Event Gri...
4.1.0                Az.EventHub                         PSGallery            Microsoft Azure PowerShell - Event Hub...
1.10.0               Az.FrontDoor                        PSGallery            Microsoft Azure PowerShell - Front Doo...
4.0.6                Az.Functions                        PSGallery            Microsoft Azure PowerShell - Azure Fun...
6.0.1                Az.HDInsight                        PSGallery            Microsoft Azure PowerShell - HDInsight...
2.0.0                Az.HealthcareApis                   PSGallery            Microsoft Azure PowerShell: Healthcare...
2.7.5                Az.IotHub                           PSGallery            Microsoft Azure PowerShell - IoT Hub s...
4.12.0               Az.KeyVault                         PSGallery            Microsoft Azure PowerShell - Key Vault...
2.2.0                Az.Kusto                            PSGallery            Microsoft Azure PowerShell: Kusto cmdlets
1.0.0                Az.LoadTesting                      PSGallery            Microsoft Azure PowerShell: LoadTestin...
1.5.0                Az.LogicApp                         PSGallery            Microsoft Azure PowerShell - Logic App...
1.1.3                Az.MachineLearning                  PSGallery            Microsoft Azure PowerShell - Machine L...
1.0.0                Az.MachineLearningServices          PSGallery            Microsoft Azure PowerShell: MachineLea...
1.3.1                Az.Maintenance                      PSGallery            Microsoft Azure PowerShell - Maintenan...
1.1.1                Az.ManagedServiceIdentity           PSGallery            Microsoft Azure PowerShell: ManagedSer...
3.0.0                Az.ManagedServices                  PSGallery            Microsoft Azure PowerShell: ManagedSer...
2.0.0                Az.MarketplaceOrdering              PSGallery            Microsoft Azure PowerShell: Marketplac...
1.1.2                Az.Media                            PSGallery            Microsoft Azure PowerShell - Media ser...
2.2.0                Az.Migrate                          PSGallery            Microsoft Azure PowerShell: Migrate cm...
4.6.0                Az.Monitor                          PSGallery            Microsoft Azure PowerShell - Monitor s...
1.1.1                Az.MySql                            PSGallery            Microsoft Azure PowerShell: MySql cmdlets
6.2.0                Az.Network                          PSGallery            Microsoft Azure PowerShell - Networkin...
1.1.2                Az.NotificationHubs                 PSGallery            Microsoft Azure PowerShell - Notificat...
3.2.0                Az.OperationalInsights              PSGallery            Microsoft Azure PowerShell - Operation...
1.6.3                Az.PolicyInsights                   PSGallery            Microsoft Azure PowerShell - Azure Pol...
1.1.0                Az.PostgreSql                       PSGallery            Microsoft Azure PowerShell: PostgreSql...
1.2.1                Az.PowerBIEmbedded                  PSGallery            Microsoft Azure PowerShell - Power BI ...
1.0.4                Az.PrivateDns                       PSGallery            Microsoft Azure PowerShell - Private D...
6.6.0                Az.RecoveryServices                 PSGallery            Microsoft Azure PowerShell - Recovery ...
1.8.0                Az.RedisCache                       PSGallery            Microsoft Azure PowerShell - Redis Cac...
1.2.0                Az.RedisEnterpriseCache             PSGallery            Microsoft Azure PowerShell: RedisEnter...
2.0.0                Az.Relay                            PSGallery            Microsoft Azure PowerShell: Relay cmdlets
1.2.0                Az.ResourceMover                    PSGallery            Microsoft Azure PowerShell: ResourceMo...
6.11.1               Az.Resources                        PSGallery            Microsoft Azure PowerShell - Azure Res...
1.4.0                Az.Security                         PSGallery            Microsoft Azure PowerShell - Azure Sec...
3.1.0                Az.SecurityInsights                 PSGallery            Microsoft Azure PowerShell: SecurityIn...
3.0.0                Az.ServiceBus                       PSGallery            Microsoft Azure PowerShell - Service B...
3.2.0                Az.ServiceFabric                    PSGallery            Microsoft Azure PowerShell - Service F...
2.0.0                Az.SignalR                          PSGallery            Microsoft Azure PowerShell - Azure Sig...
4.10.0               Az.Sql                              PSGallery            Microsoft Azure PowerShell - SQL servi...
2.1.0                Az.SqlVirtualMachine                PSGallery            Microsoft Azure PowerShell: SqlVirtual...
2.2.0                Az.StackHCI                         PSGallery            Microsoft Azure PowerShell: StackHci c...
5.10.1               Az.Storage                          PSGallery            Microsoft Azure PowerShell - Storage s...
1.0.1                Az.StorageMover                     PSGallery            Microsoft Azure PowerShell: StorageMov...
2.0.0                Az.StorageSync                      PSGallery            Microsoft Azure PowerShell - Storage S...
2.0.0                Az.StreamAnalytics                  PSGallery            Microsoft Azure PowerShell: StreamAnal...
1.0.0                Az.Support                          PSGallery            Microsoft Azure PowerShell - Azure Sup...
3.0.3                Az.Synapse                          PSGallery            Microsoft Azure PowerShell - Azure Syn...
1.2.1                Az.TrafficManager                   PSGallery            Microsoft Azure PowerShell - Traffic M...
3.1.1                Az.Websites                         PSGallery            Microsoft Azure PowerShell - App Servi...
2.0.2.182            AzureAD                             PSGallery            Azure Active Directory V2 General Avai...
2.6.1                Microsoft.Graph.Authentication      PSGallery            Microsoft Graph PowerShell Authenticat...
2.6.1                Microsoft.Graph.Identity.Directo... PSGallery            Microsoft Graph PowerShell Cmdlets
1.1.183.66           MSOnline                            PSGallery            Microsoft Azure Active Directory Modul...
1.4.8.1              PackageManagement                   PSGallery            PackageManagement (a.k.a. OneGet) is a...
2.2.5                PowerShellGet                       PSGallery            PowerShell module with commands for di...
2.6.1                Microsoft.Graph                     PSGallery            Microsoft Graph PowerShell module
2.6.1                Microsoft.Graph.Applications        PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Bookings            PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Calendar            PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.ChangeNotifications PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.CloudCommunications PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Compliance          PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.CrossDeviceExper... PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.DeviceManagement    PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.DeviceManagement... PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.DeviceManagement... PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.DeviceManagement... PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.DeviceManagement... PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Devices.CloudPrint  PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Devices.Corporat... PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Devices.ServiceA... PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.DirectoryObjects    PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Education           PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Files               PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Groups              PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Identity.Governance PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Identity.Partner    PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Identity.SignIns    PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Mail                PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Notes               PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.People              PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.PersonalContacts    PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Planner             PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Reports             PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.SchemaExtensions    PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Search              PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Security            PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Sites               PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Teams               PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Users               PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Users.Actions       PSGallery            Microsoft Graph PowerShell Cmdlets
2.6.1                Microsoft.Graph.Users.Functions     PSGallery            Microsoft Graph PowerShell Cmdlets

A script that uses both Az and MSGraph that I am now trying to run can be found here: https://github.com/briandelmsft/SentinelAutomationModules/blob/main/Deploy/GrantPermissions.ps1

It fails with

[+] Connect to the Azure AD tenant: <REDACTED>
Connect-MgGraph : The type initializer for 'Azure.Identity.AuthenticationRecord' threw an exception.
At C:\Users\<REDACTED>\Downloads\<REDACTED>.ps1:49 char:1
+ Connect-MgGraph -TenantId $TenantId -Scopes AppRoleAssignment.ReadWri ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-MgGraph], TypeInitializationException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph

[+] Connecting to  to the Azure subscription: <REDACTED>
[-] Login to Azure Management failed. Method not found: 'System.Threading.Tasks.Task`1<Azure.Identity.AuthenticationRecord> Azure.Identity.InteractiveBrowserCredential.AuthenticateAsync(Azure.Core.TokenRequestContext, System.Threading.CancellationToken)'.
Could not find tenant id for provided tenant domain '<REDACTED>'. Please ensure that the provided user is found in the provided tenant domain.
[+] Setting permission Data.Read on Get-UEBAInsights
Get-MgServicePrincipal : Authentication needed. Please call Connect-MgGraph.

I have tried running Update-Module on both Az and Graph. I have also tried to install .NET Framework 4.8.1 and 7.0, no effect.

bwblaylock commented 5 months ago

I had this issue for months. Finally found that the Azure.core dll was being loaded by the SQLServer powershell module. I removed the SQLServer ps module and Graph authentication has been working perfectly so far.