Copy-ConsoleOutput
Copies widgets, frames, text or pipeline objects to the operating-system clipboard.
Syntax
Copy-ConsoleOutput [-As <Text|Markdown|Html>] [-Culture <CultureInfo>] [-Height <Int32>] [-InputObject] <Object> [-PassThru] [-Width <Int32>] [<CommonParameters>]#All Parameter SetsDescription
Copies widgets, frames, text or pipeline objects to the operating-system clipboard.
Serializes input with ConsoleExporter as Text (default), Markdown or Html and copies the source as Unicode text. Markdown uses GFM tables, property/value lists and nested tree bullets, including the shared value presenters and totals. Text preserves the console layout inside a text fence. A rendered frame or live-session snapshot retains a fenced fallback. Windows uses its native clipboard, macOS uses pbcopy, and Linux uses wl-copy (Wayland) or xclip (X11). SSH, a missing desktop/provider or a failing provider produces a non-terminating error; use -ErrorAction Stop to catch it. No output is written unless -PassThru succeeds. -WhatIf exports without accessing the clipboard.
Examples
EXAMPLE 1
Get-Process | Select-Object -First 10 Name, Id | Format-ConsoleTable -AsWidget | Copy-ConsoleOutput -As MarkdownCopy a process table into a Markdown report
Parameters
- -As String
- Copies Text, Markdown or Html source as clipboard text (default Text).
- Possible values:
Text,Markdown,Html - -Culture CultureInfo
- The culture for values in objects and widgets.
- -Height Int32
- Height in cells, or 0 to measure the full content.
- -InputObject Object
- Widgets, rendered frames, live sessions, literal text or objects to display as tables.
- -PassThru SwitchParameter
- Also returns the serialized document after a successful copy.
- -Width Int32
- Width in cells for rendering widgets and objects (default 100); single frames keep their own size.
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.