2

我是使用 powershell 的新手,我一直在尝试解决这个问题几个小时,但我仍然无法让它工作。

先决条件:

  • 使用 Windows 10
  • 以管理员身份运行 Powershell ISE

但是当我使用“ Add-PSSnapin WebAdministration

我试图运行的命令:

Add-PSSnapin Microsoft.Sharepoint.Powershell
$siteURL = Get-SPOSite "site"
$sitelists = foreach ($web in $siteURL.AllWebs) {
foreach($list in $web.lists){ $list } }
$sitelists |select * | Export-CSV C:\liststitles.csv

它显示以下错误:

PS C:\windows\system32> Add-PSSnapin Microsoft.Sharepoint.Powershell
Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.Sharepoint.Powershell' is not installed on this computer.
At line:1 char:1
+ Add-PSSnapin Microsoft.Sharepoint.Powershell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Sharepoint.Powershell:String) [Add-PSSnapin], PSArgumentEx 
   ception
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

我还下载了“iis7psprov_x64.msi”,但我不知道如何安装它,因为我无法以管理员身份运行它。而且我也读过,它应该在“WebAdminstration”模块中可用。尝试运行文件时提示以下错误:

在此处输入图像描述

可能与此类似,但对于 Windows 10:

Windows7 中的 Add-PsSnapin WebAdministration

4

1 回答 1

5

要使用 SharePoint Online,您需要SharePoint Online 命令行管理程序PowerShell 模块。一旦安装(在您的 Windows 10 机器上),PowerShell 将自动加载您需要的命令(如Get-SPOSite),而无需手动导入模块。

可以从上面的链接下载,这里有介绍:https ://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-online/introduction-sharepoint-online-management-shell?view=sharepoint -ps&redirectedfrom=MSDN

于 2017-05-16T10:01:43.113 回答