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

Visual Studio Import-Module ExchangeOnlineManagement not working. Error AuthorizationManager check failed

I am trying to run my code from Visual Studio. Code is to create runspace and connect Exchange Online to run PowerShell script. Initial line of script is if (Get-Module -ListAvailable | Where-Object {$_.Name -eq 'ExchangeOnlineManagement'}) { …
Preeti
  • 421
  • 5
  • 14
0
votes
1 answer

Invoking powershell script within c# that calls another powershell script is throwing an UnauthorizedAccessException

The function below works well for my test private static void RunScript(string scriptText) { Runspace runspace = RunspaceFactory.CreateRunspace(); runspace.Open(); Pipeline pipeline = runspace.CreatePipeline(); …
rukiman
  • 597
  • 10
  • 32
0
votes
0 answers

Updating a GUI through a runspace

I'm trying to update a RichTextBox through a separate PowerShell RunSpace, but the runspace doesn't seem to know how to handle it whether I include the first two lines of the script or not (Add-Type and EnableVisualStyles()) or declare $TextBox1 as…
Simon W
  • 13
  • 4
0
votes
0 answers

Null-valued expression error in Powershell script with GUI Runspace

I have a configuration script in powershell that I am trying to marry with a WFP GUI. After a few failed forays with code and gui in the same thread I have been reading a number of pages about running the GUI in its own runspace. Below is the code…
0
votes
0 answers

How to implement Runspaces into a powershell script

I was very recently introduced to the concepts of Runspaces. After several YouTube videos and forum posts I get the idea as to how they work, but I struggle when trying to include it in a script of my own. if i have the code to implement…
BPengu
  • 92
  • 8
0
votes
1 answer

Running command (scriptblock) at remote machine with runspaces

Hello I have a template with runspaces that runs command and gives output to outputbox. My big question is how to make it run on remote machine? If you run script now it gives you systeminfo of current machine but I need it on remote machines.…
0
votes
0 answers

Button click to call a function that run sync hash/runspace to refresh a WPF Listview in Powershell

I want to refresh a listview each time a new item is added using a synchronized hashtable and runspace inside a function that is called on a button click event. If I put the sync hash/runspace inside the button click, it works but I need to use a…
0
votes
1 answer

How to execute appx or appxbundle from xamarin forms

I am working in Xamarin.Forms.UWP App(sideloaded) and I needed to update the app without uninstalling it, so if a package is there that package should be installed (.appxbundle file in the package) so that the app will be automatically updated into…
Riyas
  • 475
  • 1
  • 8
  • 27
0
votes
1 answer

IsComplete of AsynchronousObject returned by BeginInvoke() all true

I'm currently learning about runspaces in Powershell (my end goal is to set up a job scheduling system) to do this I wrote a basic script in order to learn and use runspaces. What I Expected To Happen: I expected that when I run the code up to the…
Nick
  • 304
  • 1
  • 12
0
votes
1 answer

Monitor the status of Runspace Pool from a different Runspace session

I am working on a GUI Wizard, this GUI Wizard will collect information from the user regarding his environment and then at the last page the tool will call 28 subscripts in a Runspace Pool. I want to monitor the status of the 28 subscripts from a…
0
votes
0 answers

Why does a getter/setter property return duplicated value?

I'm playing around with creating and destroying runspaces. Everything seems to work as expected, but when I'm trying to access Runspace.name property I get duplicated name someName someName. Here's doc reference to this property Expected…
manidos
  • 3,244
  • 4
  • 29
  • 65
0
votes
1 answer

What is the right way to manage powershell runspace without using runspace pool?

I need to execute some cmdlets in a remote powershell session, in a certain order: ex. if this distribution-group exists then add this user to the group but I keep getting errors about runspace state or that I created too many runspaces and I have…
BiancaP
  • 31
  • 2
  • 9
0
votes
1 answer

Calling a Powershell Runspace Scriptblock from a remote file

I am working on a project which starts with a GUI Wizard to get some info from the user such as EndPoint FQDN, Username, Password, etc.. Once the User has provided all required info and reach to the final page in the GUI, a start button will be…
0
votes
1 answer

Powershell background threads and return values

I'm having trouble getting background threads to work in Powershell. I'd like to use runspaces where I can plug a script into it and get updates when there is one and allow my main thread to do with that data what it needs to. I'm not sure why…
Bbb
  • 517
  • 6
  • 27
0
votes
1 answer

Powershell WFP Objects added to SyncHash are not passed to different runspaces

I am working on a project, this project is based on WPF GUI Wizard. The main idea of the Tool is that it will ask the user to input some data and at the same time perform checks on the provided data. Then after the user input all required data in…