Posted on: 7/23/2014 6:51:29 PM | Views : 354

Hello,
I hope this has not already been asked as I have been searching for good amount of time.
I have an asp.net site that runs some remote PowerShell scripts. Below is the code I Pass the script to. Everything works fine except it does not close all connections.
When I do a netstat -ao I see that each time this is called it leaves 2 sessions opened to the remote server. I go on the remote server and do a Get-PSSession and do not see any of the sessions opened. When stepping through the code, "pRunspace.Open()" creates 2 connections to the destination server, Then the "psresult = pShell.Invoke" creates another open connections. The Dispose() only closes one of the 3 connections. Upping the amount of connections or changing the idle time on the receiving server is not an option as I have already increased/lowered them and it still gets full. iisreset or closing the debugging clears the open connections. I have tried .discon ...

Go to the complete details ...