如何将 Sharepoint Powershell 添加到 Console2

如何将 Sharepoint Powershell 添加到 Console2

太好了!我想将 Sharepoint 的 Powershell 控制台添加到 Console2 中的选项卡列表中。

我已经有普通的 Powershell,但我希望自动添加 Sharepoint Powershell 管理单元。

如果我查看 Sharepoint Powershell 控制台快捷方式的属性,我会看到以下内容:

C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -NoExit  " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "

但这在 Console2 中不起作用,因此我尝试了这个,但同样不起作用:

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\psconsole.psc1"  -NoExit  " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "

每当我尝试时,它都会加载 Powershell,但不会加载 Sharepoint 控制台。我得到以下信息:

Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.SharePoint.PowerShell' is not installed on this machine.
At C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\SharePoint.ps1:3 char:13
+ Add-PsSnapin <<<<  Microsoft.SharePoint.PowerShell
+ CategoryInfo          : InvalidArgument: (Microsoft.SharePoint.PowerShell:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

尝试过也出去了。

有人知道吗?

[更新]

我读到可以通过插入来加载 64 位 Powershell

%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe

进入ShellConsole2 设置的字段。但是,如果我添加结尾,-NoExit add-pssnapin microsoft.sharepoint.powershell我仍然会收到 SharePoint 管理单元的错误。但是,系统资源管理器显示这是一个 32 位应用程序!

不管你信不信,64 位 powershell 就在这里:

C:\Windows\System32\WindowsPowerShell\v1.0

答案1

确保您使用的是 64 位版本的 Console2。32 位版本将启动 32 位版本的 PowerShell,并且如前所述,32 位版本

答案2

尝试将命令放入批处理文件中;由于引号和与号,这可能是 Console2 中的命令行解释问题。

在 Windows 资源管理器中双击批处理文件使其工作;然后在 Console2 中提供批处理文件的路径。

相关内容