Connect-MgGraph : The type initializer for 'Azure.Identity.AuthenticationRecord' threw an exception.

EnterpriseArchitect 5,511 Reputation points
2023-10-11T05:27:18.6066667+00:00

Hi Folks,

I am unable to get and retrieve the Unified groups using the Microsoft Graph powershell simple command like the below:

Connect-MgGraph -Scopes Group.Read.All, GroupMember.Read.All, User.Read.All, Files.Read.All
Get-MgGroup -Filter "groupTypes/any(c:c eq 'Unified')" -All

I got this error despite I am the Global Administrator of the company.

Connect-MgGraph : The type initializer for 'Azure.Identity.AuthenticationRecord' threw an exception.
At line:49 char:1
+ Connect-MgGraph -Scopes Group.Read.All, GroupMember.Read.All, User.Re ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-MgGraph], TypeInitializationException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph
 
Get-MgGroup : Authentication needed. Please call Connect-MgGraph.
At line:52 char:1
+ $unifiedGroups = Get-MgGroup -Filter "groupTypes/any(c:c eq 'Unified' ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-MgGroup_List], AuthenticationException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgGroup_List
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,506 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,676 questions
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 43,256 Reputation points
    2023-10-17T07:28:24.29+00:00

    Hi @EnterpriseArchitect

    Good to know it's working now. As we discussed in the comments, you need to use the Update-Module cmdlet to update the module and its dependencies to the latest version.

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    0 comments No comments

  2. User A 0 Reputation points
    2023-11-14T18:35:07.42+00:00

    It;s fucking total mess, that every command gives such a problem do you even test antyhing?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.