当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 修复“Connect-SPOService:术语“Connect-SPOService”未被识别为 cmdlet、函数、脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证该路径是正确的,然后再试一次。”错误

作者:精品下载站 日期:2024-12-14 15:24:50 浏览:13 分类:玩电脑

修复“Connect-SPOService:术语“Connect-SPOService”未被识别为 cmdlet、函数、脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证该路径是正确的,然后再试一次。”错误


问题:尝试通过 PowerShell cmdlet 连接到 SharePoint Online 时:Connect-SPOService -URL https://crescent-Admin.SharePoint.com 收到错误消息,无法从 PowerShell 连接到 SharePoint Online :
Connect-SPOService :术语“Connect-SPOService”不被识别为 cmdlet、函数、脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。

[玩转系统] 修复“Connect-SPOService:术语“Connect-SPOService”未被识别为 cmdlet、函数、脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证该路径是正确的,然后再试一次。”错误

根本原因:

当当前 PowerShell 会话中未安装或加载 SharePoint Online Management Shell 模块时,会出现错误“connect-sposervice 未被识别为 cmdlet 的名称”。要解决此错误,请按照下列步骤操作:

解决方案:

此错误消息表明加载的模块中不存在特定的 cmdlet。在这种情况下,此错误是因为“Connect-SPOService”cmdlet 是 SharePoint Online Management Shell(或 SharePoint Online PowerShell 模块)的一部分,并且未加载!因此,要解决此问题:您必须在使用 cmdlet Connect-SPOService 之前安装 SharePoint Online Management Shell(不太推荐)或 SharePoint Online PowerShell 模块(首选)。

选项 1:下载并安装 SharePoint Online Management Shell

您可以从 https://www.microsoft.com/en-us/download/details.aspx?id=35588 下载 SharePoint Online Management Shell 并将其安装到您的客户端计算机

[玩转系统] 修复“Connect-SPOService:术语“Connect-SPOService”未被识别为 cmdlet、函数、脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证该路径是正确的,然后再试一次。”错误

如果已经安装,请尝试卸载然后重新安装。

选项 2:安装 SharePoint Online PowerShell 模块

通过以下方式仔细检查是否安装了 SharePoint Online PowerShell 模块:


Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version 

您可以使用以下命令安装 SharePoint Online PowerShell 模块:


Install-Module Microsoft.Online.SharePoint.PowerShell 

如需卸载,请使用:


Uninstall-Module -Name Microsoft.Online.SharePoint.PowerShell -AllVersions -Force

这会将必要的程序集(.dll 文件)安装到路径:C:\Program Files\WindowsPowerShell\Modules\Microsoft.Online.SharePoint.PowerShell\

其他解决方法:

尽管我们不必使用“Import-Module Microsoft.Online.SharePoint.Powershell”在 PowerShell 中显式加载该模块,但请尝试暴露任何潜在问题。

如果您尝试通过代理服务器连接到 SharePoint Online PowerShell,Connect-SPOService cmdlet 连接将失败!您必须使用以下内容:


#Get Credentials to connect
$cred = Get-Credential
[System.Net.WebRequest]::DefaultWebProxy.Credentials = $cred

Connect-SPOService -Url "https://<Tenant-admin>.sharepoint.com" -Credential $cred

在另一种情况下,我必须从 GAC 中删除所有 SharePoint Online 客户端程序集,然后安装 SharePoint Online PowerShell 模块:

  1. 导航到“C:\ Windows\Microsoft.NET\assembly\GAC_MSIL”
  2. 选择以“Microsoft.SharePoint.Client”名称开头的所有文件夹并将其全部删除!
  3. 最后,安装 SharePoint Online 的 PowerShell 模块:Install-Module Microsoft.Online.SharePoint.PowerShell -force
在执行上述步骤之前,请确保您已关闭所有 PowerShell/PowerShell ISE 实例,并在安装后重新启动 PowerShell 控制台或 PowerShell ISE。

包起来

总之,SharePoint Online PowerShell 中的错误“Connect-SPOService 未被识别为 cmdlet 的名称”可以通过安装 SharePoint Online Management Shell 并在当前 PowerShell 会话中加载该模块来解决。通过执行上述答案中概述的步骤,可以解决该错误,并且可以使用 Connect-SPOService cmdlet 连接到 SharePoint Online。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯