我想使用Office365图形API,为此我使用的是Powershell,但是Connect-Graph cmdlet会引发错误

我想使用Office365图形API,为此我使用的是Powershell,但是Connect-Graph cmdlet会引发错误,powershell,office365,azure-ad-graph-api,Powershell,Office365,Azure Ad Graph Api,我想使用现代身份验证连接到Office365环境,因此我必须使用Graph API服务 我已经安装了同样需要的powershell模块。在我的Windows Powershell中,ISE连接图可通过intellisense获得,这意味着模块已成功安装 但是,当我运行命令Connect Graph时,它会导致错误: Connect-Graph : Could not load file or assembly 'System.Net.Http, Version=4.1.1.2, Culture

我想使用现代身份验证连接到Office365环境,因此我必须使用Graph API服务

我已经安装了同样需要的powershell模块。在我的Windows Powershell中,ISE连接图可通过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 framework版本。请确保安装了正确的.net framework版本,或者尝试安装最新的4.8 framework。因为我已经安装了

您正在使用哪个版本的Powershell?PS for Windows和其他版本中使用的程序集之间存在差异。@Bluf其Powershell 5.1是否可以尝试使用管理员打开Powershell ISE并再次运行该命令?我仅以管理员权限运行:谢谢!将.net framework更新为4.8解决了以下错误: