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
1 answer

Calling scriptblock from different runspace

I am working on a project to create a GUI Wizard tool, this GUI Wizard Tool first gets some data from the user and in the same time performing validation (such as connectivity, DNS Resolution, API Connection, etc..). After the GUI Wizard Tool gets…
0
votes
0 answers

Why are the results from a previous cmdlet appearing in the results of the next

I have a test suite for testing some powershell cmdlets, the problem is that if i run each test independently i will have the proper results but if i run the whole suite im getting information from other tests. i have a class that has a private…
m47791
  • 13
  • 3
0
votes
1 answer

How do I connect from a Powershell Runspace back to the main Powershell thread?

I've started thinkering around with runspaces in powershell and I was able to do the followings Create the RunSpace Pass variables to it Pass a pre-written function to it GUI/WPF shows up and I can even manipulate the elements on it (Eg. changing…
Marthon GT
  • 16
  • 4
0
votes
0 answers

Add records to Listview form Events

I have the following ui and like to add data from System.IO.FileWatcher events to the listview without blocking the UI [void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework') # Load the WPF XAML Form [xml]$XAML = @'
Proxx
  • 141
  • 2
  • 15
0
votes
1 answer

Register-ObjectEvent from runspace

I have a Barcode scanning script. it opens the RS323 Port to the handheld scanner register-objects event on "DataReceived" runs an action Scriptblock to update database fields. this all works when running normally (from mainthread) but now i would…
Proxx
  • 141
  • 2
  • 15
0
votes
1 answer

Is there a way to Out-Null $PSinstance.BeginInvoke() for Runspaces?

I tried: $PSinstance.BeginInvoke() | Out-Null but when I do this it waits for the enter key to be pressed to continue. This is weird because without the out-null it continues fine. I also tried assigning it to a variable and it behaves the same…
0
votes
1 answer

Why az login command does not work on Azure when executed with power shell command that runs from dot net code?

I have an ASP.Net Web Application which tries to log into Azure using power shell commands. The following code is being used for this purpose: Runspace runspace = RunspaceFactory.CreateRunspace(); runspace.Open(); Pipeline…
TVicky
  • 353
  • 3
  • 13
  • 36
0
votes
1 answer

Why am I not able to login to Azure using power shell commands that are being executed from ASP.Net code?

I have created an ASP.Net Web application. From this application, I am trying to execute power shell commands to log in to Azure. The command being used is 'az login'. When I run the application, I get proper response that is expected from a login…
TVicky
  • 353
  • 3
  • 13
  • 36
0
votes
1 answer

How to access a different powershell runspace without WPF-object

I worked quite a bit with PowerShell runspaces and I know it's possible to invoke commands in another runspace by using a dispatcher from WPF-objects. I create my runspaces like this: $global:A =…
T-Me
  • 1,814
  • 1
  • 9
  • 22
0
votes
0 answers

'Unauthorized operation' when executing Powershell.Invoke()

I am running the below code, as referenced from: https://stackoverflow.com/questions/17067260/invoke-powershell-command-from-c-sharp-with-different-credential I believe all necessary code is shown below but basically when GetPSResults is called, a…
tbcodes33
  • 13
  • 6
0
votes
0 answers

Net View using Runspace in Powershell

I am currently being challenged with trying to enable a script (which takes multiple machines and lists the shares on each machine) to operate with multiple threads using a Runspace. My share query is done using NET VIEW, this portion of my code…
0
votes
0 answers

Output PowerShell Runspace Function to WPF textbox

I am having trouble getting my "sync-folder" function to output to the textbox as it runs. I have tried looking over a lot of guides around the net including searching here and I'm not able to figure it out. I am hoping someone who understands this…
Obs
  • 21
  • 1
  • 3
0
votes
0 answers

access database lock errors and script crashing (oleaut32.dll)

Trying to use runspaces to do some web scraping and database inserts. when trying to multithread the job, any more than a single thread causes database lock errors and my script to crash. I'm using adodb connection to an access database. Function…
0
votes
3 answers

Runspace Analysis

Is there any materials I can read on run space analysis of an algorithm +O, +Theta , +Omega etc ? Need help for a Data Structures and Algorithm class I am taking.
captonssj
  • 301
  • 8
  • 22
0
votes
0 answers

How to dispose of Runspace and PowerShell objects from a WPF project using C#

I receive the following error after running my WPF application for the fourth consecutive time: Fail to create a runspace because you have exceeded the maximum number of connections allowed : 3 for the policy party : MaxConcurrency. Please…
Rhurac
  • 439
  • 4
  • 16