Use-ConsoleTarget
Runs a script block with ConsoleMonster output going somewhere else: a file, a text writer, any target, or a string.
Syntax
Use-ConsoleTarget [-Colors <Ansi16|Ansi256|TrueColor>] [-Glyphs <Ascii|Basic|Full>] [-ScriptBlock] <ScriptBlock> [-Width <Int32>] [<CommonParameters>]#StringUse-ConsoleTarget [-Append] [-Colors <Ansi16|Ansi256|TrueColor>] [-Glyphs <Ascii|Basic|Full>] -Path <String> [-ScriptBlock] <ScriptBlock> [-Width <Int32>] [<CommonParameters>]#PathUse-ConsoleTarget [-Colors <Ansi16|Ansi256|TrueColor>] [-Glyphs <Ascii|Basic|Full>] [-ScriptBlock] <ScriptBlock> [-Width <Int32>] -Writer <TextWriter> [<CommonParameters>]#WriterUse-ConsoleTarget [-Colors <Ansi16|Ansi256|TrueColor>] [-Glyphs <Ascii|Basic|Full>] [-ScriptBlock] <ScriptBlock> -Target <ITerminalTarget> [-Width <Int32>] [<CommonParameters>]#TargetDescription
Runs a script block with ConsoleMonster output going somewhere else: a file, a text writer, any target, or a string.
Inside the script block every ConsoleMonster command (Write-ConsoleText, Format-ConsoleTable, Write-ConsoleMarkup, live dashboards, prompts) writes to the target instead of the console. With -Path the output goes to a UTF-8 file, with -Writer to a TextWriter, with -Target to a target object (ConsoleMonster.Output.ITerminalTarget); with none of them it is returned as one string. -Width, -Glyphs and -Colors lay the output out for the file or string; prompts there have nobody to answer and use their defaults. The script block's own output is passed through.
Examples
EXAMPLE 1
Use-ConsoleTarget -ScriptBlock { }EXAMPLE 2
Use-ConsoleTarget -ScriptBlock { } -Path 'C:\Path'EXAMPLE 3
Use-ConsoleTarget -ScriptBlock { } -Target 'Value'Parameters
- -Colors ColorDepth
- The colour depth for -Path, -Writer or the string (default None: plain text).
- Possible values:
Ansi16,Ansi256,TrueColor - -Glyphs GlyphTier
- The glyph tier for -Path, -Writer or the string (default Ascii).
- Possible values:
Ascii,Basic,Full - -ScriptBlock ScriptBlock
- The commands whose output goes to the target.
- -Width Int32
- The width in cells for -Path, -Writer or the string (default 80).
- -Append SwitchParameter
- Appends to the file instead of replacing it.
- -Path String
- A file to write to (UTF-8 without a byte order mark; replaced unless -Append).
- -Writer TextWriter
- A TextWriter to write to (it stays open).
- -Target ITerminalTarget
- A target object (ConsoleMonster.Output.ITerminalTarget).
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.