0

当我尝试Add-PSSnapin Microsoft.SharePoint.Powershell在 SharePoint Online 命令行管理程序中运行命令时

我收到以下错误:

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 Management Shell 一起安装(这是一个全新的下载),所以为什么不让我安装它

我可以使用 $AdminURL、$AdminName 和 $Password 登录到 Sharepoint,所以这不是世界末日(并证明这应该可行),但显然使脚本不太容易跨站点运行,因为它必须每次都修改更改 url 和 adminname

编辑:我在另一篇文章中读到,添加这个模块(不是 snapin)可以解决我的错误问题Get-SPSite is not recognized as the name of a cmdlet, function, script file, or operable programGet-SPWebApplication is not recognized as the name of a cmdlet, function, script file, or operable program但是,这并没有解决我的问题......

4

1 回答 1

0

正如用户 @kuzimoto 所提到的,我使用的命令与 SharePoint Online 不兼容,旨在与 SharePoint Server 结合使用。

正确的连接方法是使用命令Connect-SPOService并通过那里传递凭据,或者只是将它们硬编码到您的脚本中。

于 2019-05-14T19:20:47.487 回答