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

EnterpriseArchitect 6,041 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
Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Graph
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 46,376 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 is a total mess; every command gives such a problem, do you even test anything?

    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.