我想使用现代授权连接到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
它运行成功,这意味着文件是存在的,也许不是正确的版本,但我无法找到当前版本的汇编来验证。
任何帮助在这一点上是感激的。
由于我也有ps 5.1,并且没有运行connect-graph的问题,我只能假设你可能没有安装正确的.net框架版本。确保你已经安装了正确的.net框架版本,也许可以尝试安装最新的4.8框架,因为我已经安装了。