TestimoX

API Reference

Class

PowerShellExecutionEnvironment

Namespace TestimoX.PowerShell
Assembly TestimoX
Implements
IDisposable

Provides a configured PowerShell runspace with required modules loaded.

Inheritance

  • Object
  • PowerShellExecutionEnvironment

Remarks

This class manages a runspace and imports modules so that cmdlets can be executed without worrying about dependencies.

Examples


using var env = new PowerShellExecutionEnvironment(new PowerShellModuleManager());
using PS ps = await env.CreateConfiguredPowerShellAsync(new[] { "DnsServer" }, CancellationToken.None);

        

Constructors

public PowerShellExecutionEnvironment(PowerShellModuleManager moduleManager) #

Initializes a new instance of the PowerShellExecutionEnvironment class.

Parameters

moduleManager TestimoX.PowerShell.PowerShellModuleManager requiredposition: 0
Module manager used to load dependencies.

Methods

public async Task<PowerShell> CreateConfiguredPowerShellAsync(String[] requiredModules, CancellationToken cancellationToken) #
Returns: Task<PowerShell>

Creates a PowerShell instance with modules imported.

Parameters

requiredModules System.String[] requiredposition: 0
cancellationToken System.Threading.CancellationToken requiredposition: 1

Examples


using PS ps = await env.CreateConfiguredPowerShellAsync(requiredModules, CancellationToken.None);
ps.AddCommand("Get-Process");
var results = await ps.InvokeAsync();

        
public virtual Void Dispose() #
Returns: Void