Invoke-SpectreScriptBlockQuietly
Description
This function invokes a script block in a background job and returns the output. It also provides an option to suppress the output even more if there is garbage being printed to stderr if using Level = Quieter.
Examples
EXAMPLE 1
$result = Invoke-SpectreCommandWithProgress { param ( $Context ) $task1 = $Context.AddTask("Starting a process that generates noise") $task1.Increment(50) $value = Invoke-SpectreScriptBlockQuietly -Level Quiet -Command { Write-Output "Things..." Write-Output "And stuff..." Write-Error "This is an error" Start-Sleep -Seconds 3 Write-Output "But it shouldn't break progress bar rendering" } $task1.Increment(50) return $value}Write-SpectreHost "Result: $result"
Parameters
Command
The script block to be invoked.
Type | Required | Position | PipelineInput |
---|---|---|---|
[ScriptBlock] | false | 1 | false |
Level
Suppresses the output by varying amounts.
Valid Values:
- Quiet
- Quieter
Type | Required | Position | PipelineInput |
---|---|---|---|
[String] | false | 2 | false |
Syntax
Invoke-SpectreScriptBlockQuietly [[-Command] <ScriptBlock>] [[-Level] <String>] [<CommonParameters>]