Questions tagged [runspace]

In the context of using PowerShell commands with managed code a runspace is the operating environment for the commands invoked by the host application.

This environment includes the commands and data that are currently present, and any language restrictions that currently apply.Host applications can use the default runspace that is provided by Windows PowerShell, or they can create their own runspaces by using the RunspaceFactory class. By using that class, The host application can create individual runspaces or they can create a pool of runspaces. Once a runspace is created and opened, the host application can invoke commands synchronously or asynchronously by using a PowerShell object. For more information see Writing a Windows PowerShell Host Application

283 questions
0
votes
0 answers

Synchronized variable don't work for Remote Runspace

code below will demonstrate usage of the Synchronized variable for Runspaces. You can use any ip/hostname for $ComputerName as long it's accessible, Powershell remoting is verified by Enter-PSSession and also you added credential to Windows…
ALIENQuake
  • 520
  • 3
  • 12
  • 28
0
votes
0 answers

Is this a good implementation of PowerShell runspaces?

I have three components in my PowerShell script. I'm using a runspace for each : core, GUI and timer. Core is for executing some actions, GUI for showing if action in core is completed and timer is needed for one action in core. I'm not sure It's a…
mrplume
  • 183
  • 1
  • 3
  • 18
0
votes
1 answer

C# calling PowerShell asynchronously but only importing modules once

I am trying to work out an efficient way of calling a Powershell cmdlet for 20-30 files asynchronously. Although the below code is working, the Import-Module step is run for every file which is processed. Unfortunately this Module takes between 3…
Gavin
  • 1
  • 1
0
votes
1 answer

Some of the PowerShell module (Cluster cmdlets) does not get loaded when I create RunSpace on a localhost without providing runspaceconnectioninfo

Please refer the sample below: RunspaceSample(string.Empty); fails with The term 'Add-VMToCluster' is not recognized as the name of a cmdlet. Whereas the RunspaceSample("localhost") or RunspaceSample("somecomputerName") succeed. Any pointer why is…
Vipin Kumar
  • 136
  • 1
  • 9
0
votes
0 answers

How to stop powershell runspace before reCall it

I have a list of items on a powershell GUI, when I clic one, I call the same runspace $runspace.BeginInvoke() But if I click on quickly the first instance is in progress for the second item. I Stop it ($runspace.stop() and $runspace.dispose())…
Alban
  • 3,105
  • 5
  • 31
  • 46
0
votes
2 answers

Converting a powershell script to Runspace

I wrote a quick script to find the percentage of users in one user list (TEMP.txt) that are also in another user list (TEMP2.txt) It worked great for a while until my user lists got up above a couple 100,000 or so... its too slow. I want to…
KruLL
  • 1
  • 1
0
votes
0 answers

Remote PowerShell connection script works for exchange PS but not for windows PS

I've written a function to interact with the Exchange Shell remotly. Now I want to use it for the normal Windows PS. So I changed the Shell Uri in WSManConnectionInfo to http://schemas.microsoft.com/powershell/Microsoft.PowerShell. The function…
GrindelOh
  • 448
  • 1
  • 10
  • 24
0
votes
1 answer

How do I iterate over PSObject in C#?

From my C# code, I'm calling a PowerShell file. This PowerShell file calls an API like this: $tickets = Invoke-RestMethod -uri 'x' return $tickets.value From my C# code, I'm storing the returned result in a variable like this: var tickets =…
90abyss
  • 7,037
  • 19
  • 63
  • 94
0
votes
0 answers

Why is my powershell GUI lagging?

I am trying to learn how to update GUI's in realtime using powershell runspace. I have this simple little code here that starts a loop from 1 to 50 and outputs them to a textbox on the GUI. The GUI doesn't lockup but it lags terribly. If I try to…
Bregs
  • 87
  • 3
  • 15
0
votes
1 answer

manage objects and variables from another PowerShell runspace

I am currently working with the System.Timers.Timer object in Powershell. The Problem i have encountered is, that when you register to the "Elapsed" event Register-ObjectEvent -InputObject $timer -EventName Elapsed -SourceIdentifier ThirtySecTimer…
dopi
  • 15
  • 4
0
votes
1 answer

Piping ListView items in separate runspace

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" …
Deadly-Bagel
  • 1,612
  • 1
  • 9
  • 21
0
votes
1 answer

I created function to run script of "Power Shell script"

I created function to run script of "Power Shell script". I use Pipeline and Runspace ro run script (ex: power shell get-service) and run 1.000.000 times script “get-service” I see: - when run 1 script (1 pipeline and 1 runspace) then ram of…
0
votes
1 answer

Utilize Results from Synchronized Hashtable (Runspacepool 6000+ clients)

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…
0
votes
0 answers

Why doesn't my GUI appear when running from powershell.exe -file?

I am writing a Powershell script utilizing WPF with the methods shown here: http://learn-powershell.net/2012/10/14/powershell-and-wpf-writing-data-to-a-ui-from-a-different-runspace/. My script runs perfectly when I execute it from the within…
cjones26
  • 3,459
  • 1
  • 34
  • 51
0
votes
1 answer

Powershell script getting called twice from C#.net code

I have following code which I call from my C#.net service which results in calling the powershell script twice. using (Runspace runspace = RunspaceFactory.CreateRunspace()) { runspace.Open(); …
pjog
  • 3
  • 3
1 2 3
18
19