runspace

Utilize Results from Synchronized Hashtable (Runspacepool 6000+ clients)

[亡魂溺海] 提交于 2019-12-04 05:48:59
问题 Adapting a script to do multiple functions, starting with test-connection to gather data, will be hitting 6000+ machines so I am using RunspacePools adapted from the below site; http://learn-powershell.net/2013/04/19/sharing-variables-and-live-objects-between-powershell-runspaces/ The data comes out as below, I would like to get it sorted into an array (I think that's the terminology), so I can sort the data via results. This will be adapted to multiple other functions pulling anything from

Memory leak using Powershell Remote Calls in C#

烂漫一生 提交于 2019-12-04 03:08:19
I have a windows service that is doing a lot of exchange remote calls to get some server information. I noticed that as longs as the time passes the memory used by the service starts growing until a memory exception is thrown. I have searched and it looks like there is a known memory leak in the System.Management.Automation that does not dispose all the memory of the Runspace created while calling the close and/or dispose method. I reviewed a post that suggest using the CreateOutOfProcessRunspace of the RunspaceFactory but not sure how to use it. Here is how the issue can be reproduced: (

Utilize Results from Synchronized Hashtable (Runspacepool 6000+ clients)

笑着哭i 提交于 2019-12-02 10:20:50
Adapting a script to do multiple functions, starting with test-connection to gather data, will be hitting 6000+ machines so I am using RunspacePools adapted from the below site; http://learn-powershell.net/2013/04/19/sharing-variables-and-live-objects-between-powershell-runspaces/ The data comes out as below, I would like to get it sorted into an array (I think that's the terminology), so I can sort the data via results. This will be adapted to multiple other functions pulling anything from Serial Numbers to IAVM data. Is there any way I can use the comma delimited data and have it spit the

ImportPSModule Failure Detection

℡╲_俬逩灬. 提交于 2019-12-01 20:51:43
I am trying to use InitialSessionState.ImportPSModule in order to import a Powershell module. I am interested in knowing if importing of the module failed due to any reason (e.g file not found etc.). Putting such code in the try block does not raise an exception in the case of failure and the function seems to fail silently and continue if it is not able to import the module. Is there a way to be alerted in the code if the import fails? I am trying to do something like the following. In the code below, the module "TestModule1234" does not exist. The catch block does not catch an exception.

Piping ListView items in separate runspace

青春壹個敷衍的年華 提交于 2019-11-29 17:28:55
I have a form written in PowerShell (as it uses PS to run commands over hundreds of servers) but this bit had me stumped for awhile: $listview.Invoke([System.Action[String]]{ Param ( [String]$data ) write-warning "1" $LVitem = ($LVresults.Items | Where { $_.Name -eq "Test Account" }) write-warning "2" $LVitem.Tag.Output += $data + "`n" }, "Testing") It's in a separate runspace that runs an Invoke-Command to a specific server and pipes the output to this code block. Now if I run the Where statement in the main runspace (where the form is created) it works perfectly fine. In the separate

Write PowerShell Output (as it happens) to WPF UI Control

三世轮回 提交于 2019-11-29 15:47:23
I've been reading blogs about writing to the UI from different runspaces ( http://learn-powershell.net/2012/10/14/powershell-and-wpf-writing-data-to-a-ui-from-a-different-runspace/ ). I'm basically trying to make it so I can click a button in the UI and run a PowerShell script and capture the output of that script as it happens and update the WPF UI control without freezing up the UI. I've tried a basic example of just writing some output directly, but it seems to hang the UI. I'm using runspaces and dispatcher, but I seem to be stuck on something. Any ideas? Thanks. Add-Type –assemblyName

How do I host a Powershell script or app so it's accessible via WSManConnectionInfo? (like Office 365)

对着背影说爱祢 提交于 2019-11-28 06:53:59
The only ways I know to connect to a remote runspace include the following parameters WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, "localhost", 80, "/Powershell", "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential); or WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, "localhost", 5985, "/wsman", "http://schemas.microsoft.com/powershell/Microsoft.Powershell", credential); How do I set up my own custom Powershell object so I can expose it through HTTP? What are the correct parameters to use and how do I set them up? There are

How do I host a Powershell script or app so it's accessible via WSManConnectionInfo? (like Office 365)

Deadly 提交于 2019-11-27 01:34:44
问题 The only ways I know to connect to a remote runspace include the following parameters WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, "localhost", 80, "/Powershell", "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential); or WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, "localhost", 5985, "/wsman", "http://schemas.microsoft.com/powershell/Microsoft.Powershell", credential); How do I set up my own custom Powershell object so I can