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

GUI-Runspaces-PoshRSJob module

I have created also a thread in powershell.org asking for help but was directed in your great community in order to get help. For reference the link is https://powershell.org/forums/topic/gui-runspaces-poshrsjob-module/ and tried to copy it here…
0
votes
1 answer

Powershell how to change the defaultrunspace set disableformatupdates false

I've a need to change the "DisableFormatUpdates" session state value within my powershell. I've figured out how to retrieve the initial session…
Falcones
  • 109
  • 1
  • 5
  • 15
0
votes
1 answer

Multi-Runspace PowerShell/XAML script crashing on button click

I have a script which uses asynchronous runspaces in order to display a XAML/WPF GUI while processing stuff in the background. When I click the button, it crashes, but only when in a specific state. Let me elaborate. The script begins with pinging a…
Nick
  • 1,178
  • 3
  • 24
  • 36
0
votes
1 answer

powershell invoke-command returns upon completion

I would like to parallel copy using robocopy and returning log data when it is done. if i were to use invoke-command server1,server2,server3 { robocopy }, it spits out the logs as it is copying for $1, $2, $3. this getting very confusing and hard…
0
votes
2 answers

Using PowerShell to Read Office 365 Group Members in C#

I'm attempting to connect to an Office 365 Group and list the membership of the Group using Powershell through a C# Project. From this article, I've determined the command I need to use is Get-UnifiedGroupLinks –Identity groupalias –LinkType…
MrMatt
  • 175
  • 2
  • 12
0
votes
1 answer

runspacepool job with a function rather than a script block

I have a scenario where I want to put a function in a powershell Module, and then in one situation load the module and call the function in a loop, but in another situation I want to load the module and use the function in parallel using a Runspace.…
Gordon
  • 6,257
  • 6
  • 36
  • 89
0
votes
0 answers

Where can I find the returnvalue when running invoke-command in a runspaces?

I have this PSSession which returns the Date from a Remote System. Start-Session is a function which collects Host,User and Password and starts a PSSession. $return is the returnvalue # Start Session $Session = Start-Session # Start Commands…
Dirk.R.
  • 1
  • 1
0
votes
1 answer

Check whether a RunspacePool is already open on a machine

I have a process that runs Powersell script on a VM. This script defines a RunspacePool on the VM and sets threshold (no. of Runspaces) based on the resource capability of that VM. This process is recurring so I do not want it to keep defining and…
0
votes
1 answer

Error launching PowerShell - Cannot perform operation because object "runspace" has already been disposed

When attempting to launch powershell, I get the following message: The shell cannot be started. A failure occurred during initialization: Cannot perform operation because object "runspace" has already been disposed. Object name: 'runspace'. I…
Jon Barker
  • 1,788
  • 15
  • 25
0
votes
1 answer

Persistent Runspace in .net (C#)

I want to create a runspace with in some webpage code that a power shell session will run in. I want this run space to be created when the user opens the page up, and remain open until it is closed. So for example the code below is for one button…
DevilWAH
  • 2,553
  • 13
  • 41
  • 57
0
votes
2 answers

Hash Array into RunSpace

I am getting strange behaviour when passing an array object from my Main script into RunSpace code block. I am trying to retrieve values using a Where-Object statement within the RunSpace code block. But produces an error relating to null method. If…
Anon
  • 1
0
votes
2 answers

Check if form is Opened Winform / Powershell

I'm searching how I could check if a winform form is opened with Powershell, like this response for VB.net. I'm working with two runspaces, and I need to start the second, when my form is opened. My first runspace is for the GUI. When the UI…
mrplume
  • 183
  • 1
  • 3
  • 18
0
votes
1 answer

Does a Powershell script using system.managment.automation would still run after its C# host die?

I want to add PowerShell capabilities to a C# program and I have embedded the system.managment.automation.dll assembly as a reference. I have found on StackOverflow two ways to call a PowerShell scrit from C# : Using runspaces: Not using…
cgcmake
  • 103
  • 3
0
votes
1 answer

How to add label from a different runspace in a Powershell GUI?

In my Powershell GUI I have two mode : connection and deconnection. For each there is a list of step. This list is read from a xml and then load into a flowlayout panel, as a label for each step. So If I have 8 steps for connection, I will have 8…
mrplume
  • 183
  • 1
  • 3
  • 18
0
votes
1 answer

RunSpacePool rebooting computers does not record success

I'm working on a script that will reboot a list of servers at a later time using the below script scheduled in Task Scheduler. The script uses RunSpacePools to process multiple servers but what seems to happen is my script fails to record the…
user4317867
  • 2,397
  • 4
  • 31
  • 57