【发布时间】:2019-10-01 20:29:47
【问题描述】:
当我尝试在 SharePoint Online 命令行管理程序中运行命令 Add-PSSnapin Microsoft.SharePoint.Powershell 时
我收到以下错误:
Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.SharePoint.Powershell` is not installed on this computer
+ CategoryInfo: InvalidArgument: (Microsoft.SharePoint.Powershell:string) [Add-PSSnapin], PSArgumentException
据我了解,无论如何它都应该随 SharePoint Online 命令行管理程序一起安装(这是一个全新的下载),所以它为什么不让我安装它
我可以使用 $AdminURL、$AdminName 和 $Password 登录 Sharepoint,所以这不是世界末日(并证明这应该有效),但显然会使脚本不太容易跨站点运行,因为它必须每次修改url和adminname
编辑:我在另一篇文章中读到,添加此模块(不是 snapin)将解决我的错误问题 Get-SPSite is not recognized as the name of a cmdlet, function, script file, or operable program 和 Get-SPWebApplication is not recognized as the name of a cmdlet, function, script file, or operable program 但是,这并没有解决我的问题......
【问题讨论】:
-
43997587 的可能重复项。你能运行
Connect-SPOService吗?根据另一个线程,它是一个模块,而不是一个管理单元,所以它不需要像这样加载。 -
Install-Module -Name Microsoft.Online.SharePoint.PowerShellPowershell 应该在提升模式下运行(以管理员身份) 据我所知,微软决定放弃管理单元。只要模块位于$env:psmodulePath路径之一中,当您使用模块中的任何命令时,模块将自动导入。 -
@jblaupunkt 尝试使用
get-module -listavailable查找Sharepoint 模块并尝试import-module <SharePpoint modulename>或使用get-command "Get-SPWebApplication" 检查它所在的模块并导入该模块 -
@jblaupunkt 您是在尝试访问本地 SharePoint 服务器,还是在线访问?因为您尝试使用的命令
Get-SPSite和Get-SPWebApplication旨在与 Sharepoint Server 一起使用。 -
@jblaupunkt 是的,这应该可以解决问题。
标签: powershell sharepoint office365