简体   繁体   English

Powershell运行空间池能否建立远程连接并加载管理单元?

[英]Can the Powershell runspace pool establish a remote connection and load a snap-in?

I'm working on a multi-tenant SharePoint provisioning application and plan to use Powershell for most of the provisioning. 我正在开发一个多租户SharePoint配置应用程序,并计划将Powershell用于大多数配置。 I would like to use remote Powershell to invoke my cmdlets from a server that does not have SharePoint installed. 我想使用远程Powershell从未安装SharePoint的服务器上调用我的cmdlet。 However, before I can run any of the SharePoint cmdlets the SharePoint snap-in must be loaded into the runspace. 但是,在我可以运行任何SharePoint cmdlet之前,必须将SharePoint管理单元加载到运行空间中。 Unfortunately, I can't find a way to provide both the connection info and the snap-in when creating the runspace pool. 不幸的是,在创建运行空间池时,我找不到同时提供连接信息和管理单元的方法。

Runspace pool with connection 带连接的运行空间池

    Dim connectionUrl = New Uri(String.Format("http://{0}/wsman/", remoteServer))
    Dim connectionInfo = New WSManConnectionInfo(connectionUrl)

    Me._runspacePool = RunspaceFactory.CreateRunspacePool(10, 20, connectionInfo)

Runspace pool with snap-in 带管理单元的运行空间池

    Dim sessionState = InitialSessionState.Create("Microsoft.Sharepoint.Powershell")
    Me._runspacePool = RunspaceFactory.CreateRunspacePool(sessionState)

Does anyone know of a way to do this? 有人知道这样做的方法吗?

If you follow the directions below, you should be able to run any SharePoint cmdlets as if you were on the server. 如果按照以下说明进行操作,则应该能够像在服务器上一样运行任何SharePoint cmdlet。

http://blogs.msdn.com/b/opal/archive/2010/03/07/sharepoint-2010-with-windows-powershell-remoting-step-by-step.aspx http://blogs.msdn.com/b/opal/archive/2010/03/07/sharepoint-2010-with-windows-powershell-remoting-step-by-step.aspx

Let me know if you have any trouble setting that up...I've recently done it myself and have it working quite well. 如果您在设置时遇到任何麻烦,请告诉我...我最近亲自完成了该程序,并使其运行良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM