powershell 错误:未找到方法:'Void Microsoft.Graph.Authentication.AzureIdentityLogisticTokenProvider.. ctor

3htmauhk  于 12个月前  发布在  Shell
关注(0)|答案(1)|浏览(170)

大家好,我得到这个错误。有人可以帮助我吗?我的代码是这样的:

PS C:\Windows\system32> $userObjectID = (Get-MgUser -Filter "(UserPrincipalName eq '$username')").Id

字符串
错误代码:

Get-MgUser : 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
+ $userObjectID = (Get-MgUser -Filter "(UserPrincipalName eq '$username ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-MgUser_List], MissingMethodException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgUser_List`

iugsix8n

iugsix8n1#

Get-Mg用户:未找到方法:'Void Microsoft.Graph.Authentication.AzureIdentityCredit.TokenProvider.. ctor(Azure.Core.TokenCredential,System.String[],Microsoft.Kiota.Authentication.Azure.ObservabilityOptions,System.Str
上面的错误信息表示由于**Microsoft Graph SDKAzure Identity SDK.之间的版本不匹配,Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider中缺少某些参数
您可以参考Shahid Sayyed的类似thread
在我的环境中,我使用以下命令安装了最新版本的
Microsoft-graph SDK version-2.9.0**模块:

命令:

Install-Module Microsoft.Graph -RequiredVersion 2.9.0 -Force -AllowClobber

字符串
安装后,使用**Get-module**命令进行检查。

输出:

PS C:\WINDOWS\system32> Get-module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.12.1     Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}
Script     2.9.0      Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext...}
Script     2.9.0      Microsoft.Graph.Users               {Get-MgUser, Get-MgUserCount, Get-MgUserCreatedObject, Get-MgUserCreatedObjectAsServicePrincipal...}


在我的环境中安装它之后,我尝试了相同的命令,它成功地执行了。

命令:

Connect-MgGraph
$username="<Your-userprinicipal-name>" 
$userObjectID = (Get-MgUser -Filter "(UserPrincipalName eq '$username')").Id 
$userObjectID

输出:

PS C:\WINDOWS\system32> $username="vxxxx.onmicrosoft.com"
PS C:\WINDOWS\system32> $userObjectID = (Get-MgUser -Filter "(UserPrincipalName eq '$username')").Id
PS C:\WINDOWS\system32> $userObjectID
ef2746a6-f0e3-4b67-bde8-xxxxxf9


x1c 0d1x的数据

参考:

PowerShell Gallery | Microsoft.Graph.Authentication 2.9.0

相关问题