public override async Task <PersistedConfiguration> CollectAsync(IOperationCollectionContext context) { var scriptName = this.DefaultArgument.AsString(); if (string.IsNullOrWhiteSpace(scriptName)) { this.LogError("Bad or missing script name."); return(null); } if (context.Simulation) { this.LogInformation("Executing PowerShell Script..."); return(null); } var result = await PSUtil.ExecuteScriptAssetAsync( logger : this, context : context, fullScriptName : scriptName, arguments : this.NamedArguments, outArguments : this.OutArguments, collectOutput : true, progressUpdateHandler : (s, e) => this.currentProgress = e, executionMode : PsExecutionMode.Collect ); this.collectedConfiguration = new PSPersistedConfiguration(result); return(this.collectedConfiguration); }
public override Task ExecuteAsync(IOperationExecutionContext context) { if (context.Simulation) { this.LogInformation("Executing PowerShell Script..."); return(Complete); } var fullScriptName = this.DefaultArgument.AsString(); if (fullScriptName == null) { this.LogError("Bad or missing script name."); return(Complete); } return(PSUtil.ExecuteScriptAssetAsync( logger: this, context: context, fullScriptName: fullScriptName, arguments: this.NamedArguments, outArguments: this.OutArguments, collectOutput: false, progressUpdateHandler: (s, e) => Interlocked.Exchange(ref this.currentProgress, e) )); }