How to share a server connection between different powershell runspaces in c# on a web application
-
I'm working on a web project and I need to do the following. I want to run different cmdlets on a VMM server (https://technet.microsoft.com/en-us/library/dn246490.aspx). Right now when I need to run a cmdlet I open a runspace, connect to the VMM server using this cmdlet: https://technet.microsoft.com/library/jj613273(v=sc.20).aspx and then disconnect. The problem is that disconnect doesn't work as expected and so I have memory leaks. The solution is to use one connection to the server,using the previous cmdlet, and then perform all other actions via this connection (on new runspaces). So I need to share the fact that I'm connected on each new runspace I open. I suppose I should use the RunspacePool class and maybe the InitialSessionState member but I'm not sure. Thanks for your help! ps: http://stackoverflow.com/questions/28254778/how-to-share-a-server-connection-between-different-powershell-runspaces-in-c-sha[^]
-
I'm working on a web project and I need to do the following. I want to run different cmdlets on a VMM server (https://technet.microsoft.com/en-us/library/dn246490.aspx). Right now when I need to run a cmdlet I open a runspace, connect to the VMM server using this cmdlet: https://technet.microsoft.com/library/jj613273(v=sc.20).aspx and then disconnect. The problem is that disconnect doesn't work as expected and so I have memory leaks. The solution is to use one connection to the server,using the previous cmdlet, and then perform all other actions via this connection (on new runspaces). So I need to share the fact that I'm connected on each new runspace I open. I suppose I should use the RunspacePool class and maybe the InitialSessionState member but I'm not sure. Thanks for your help! ps: http://stackoverflow.com/questions/28254778/how-to-share-a-server-connection-between-different-powershell-runspaces-in-c-sha[^]