PowerShellScriptResource Methods
Class Methods 2 members
Represents a PowerShell script resource.
Breaks the PowerShell script execution.
public class PowerShellScriptResource{ public Task<bool> BreakAsync() { // ... }}StartAsync(ILogger, ResourceNotificationService, CancellationToken) Section titled StartAsync(ILogger, ResourceNotificationService, CancellationToken) Task Starts the execution of the PowerShell script asynchronously, publishing state updates and handling script arguments as needed.
public class PowerShellScriptResource{ public Task StartAsync( ILogger scriptLogger, ResourceNotificationService notificationService, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
scriptLogger ILogger The logger used to record informational and error messages related to the script execution. Cannot be null. notificationService ResourceNotificationService The service used to publish resource state updates during script execution. Cannot be null. cancellationToken CancellationToken optional A cancellation token that can be used to cancel the script execution. Returns
Task A task that represents the asynchronous operation of starting and monitoring the PowerShell script. Exceptions
ArgumentOutOfRangeException Thrown if the PowerShell invocation state is not recognized when handling state changes. Remarks
State changes during script execution are published using the provided notification service. Script arguments are resolved and added prior to invocation. If the script pipeline is stopped intentionally, the resulting exception is ignored. If awaited, this method will complete when the script execution finishes, either successfully, with an error, or by being stopped. The method also sets up event handlers to log output and errors from the script execution, and to publish state updates using the provided notification service.