I’m working on a multi-tenant SharePoint provisioning application and plan to use Powershell for most of the provisioning. I would like to use remote Powershell to invoke my cmdlets from a server that does not have SharePoint installed. However, before I can run any of the SharePoint cmdlets the SharePoint snap-in must be loaded into the runspace. 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.
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.