我想使用Office365 Graph APIs,为此我使用Powershell,但是Connect-Graph cmdlet抛出了错误。

问题描述 投票:0回答:1

我想使用现代授权连接到Office365环境,因此我必须使用Graph API服务。

我已经安装了同样需要的powerhell模块。在我的Windows Powershell ISE中,Connect-Graph可通过intellisense使用,这意味着模块已成功安装。

然而,当我运行Connect-Graph命令时,却出现了错误。

Connect-Graph : Could not load file or assembly 'System.Net.Http, Version=4.1.1.2, 
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system 
cannot find the file specified.
At line:1 char:1
+ Connect-Graph
+ ~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-Graph], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.Graph.PowerShell.Aut 
   hentication.Cmdlets.ConnectGraph

看起来它想要4.1.1.2版本的System.Net.Http的文件,但它找不到。我只是在猜测这个错误。

而当我运行这个命令时 Add-Type -AssemblyName System.Net.Http 它运行成功,这意味着文件是存在的,也许不是正确的版本,但我无法找到当前版本的汇编来验证。

任何帮助在这一点上是感激的。

powershell office365 azure-ad-graph-api
1个回答
1
投票

由于我也有ps 5.1,并且没有运行connect-graph的问题,我只能假设你可能没有安装正确的.net框架版本。确保你已经安装了正确的.net框架版本,也许可以尝试安装最新的4.8框架,因为我已经安装了。

© www.soinside.com 2019 - 2024. All rights reserved.