Runspace
A runspace is a fundamental concept in PowerShell, representing an isolated environment where PowerShell commands are executed. Think of it as a sandbox or a session for running PowerShell code. Each runspace has its own state, including the current directory, loaded modules, variables, and scripts. This isolation is crucial for managing and executing scripts reliably, especially in scenarios where multiple scripts might be running concurrently or in complex applications.
When you open a PowerShell console, you are interacting with a default runspace. Programmatically, you can create
The runspace manages the execution pipeline, handles script parsing, and tracks the state of the PowerShell