Install ADFS on Azure VM step by step

Working with RunSpace in Powershell

Runspace is good a method to run multiple PowerShell jobs without putting an overhead on system as the runspace run jobs under the same process.

In this post I will be talking about how we can create a simple powershell runspace to run the scripts which takes much time in the background and keep our session free for the other work.

You can also go through my other post in this series.

Run the below CMD to run the RunSpace Instance.


Now lets create a new Job Under the Runspace instance we created above


Now Lets open the RunSpace.


Now when our Runspace is open, lets see what methods are available with the PowerShell.

We can add our script using the below method.


Note: If your script required parameters you can use the addArgument() method, I will talk about it in my Next Post.

$Data = $Powershell.EndInvoke($AsyncObject)

That’s it for today, Below is the full Sample Code used in this Post.

$Data = $job.EndInvoke($AsyncObject)