Skip to content
ConsoleMonster
Cmdlet

Show-ConsoleStatusLine

Module
ConsoleMonster
Inputs
None

Shows one status line that updates in place, with an optional spinner, clock and elapsed time.

Syntax

Show-ConsoleStatusLine
[-BackgroundColor <Object[]>]
[-Color <Object[]>]
[-Complete]
[-Decoration <String[]>]
[-Markup <String>]
[-Role <ThemeToken>]
[-ShowElapsed]
[-ShowTimestamp]
[-Spinner]
[-Status <StatusKind>]
[[-Text] <Object[]>]
[-TimestampFormat <String>]
[<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Each call replaces the line (Write-Color style pieces, colours, -Markup, -Decoration and -Role as in Write-ConsoleText). -Spinner, -ShowTimestamp and -ShowElapsed keep refreshing about ten times a second between calls. -Complete writes the final line (with -Status Pass, Fail or Warn for a marker) and moves on. The refresh stops by itself when other output or the prompt moves the cursor, so it never draws over them. In redirected output, CI, transcripts, jobs and other non-console hosts each call writes a normal line instead (unchanged repeats are skipped).

Examples

Example 1

foreach ($file in $files) { Show-ConsoleStatusLine 'Copying ', $file.Name -Color Gray, Cyan -Spinner -ShowElapsed; Copy-Item $file.FullName $target }
Show-ConsoleStatusLine "Copied $($files.Count) files" -Status Pass -ShowElapsed -Complete

A copy loop with a spinner and elapsed time

Example 2

Show-ConsoleStatusLine 'You have waited ' -Color Green -BackgroundColor Blue -ShowTimestamp -ShowElapsed; Start-Sleep 5; Show-ConsoleStatusLine 'Done' -Status Pass -Complete

A waiting line with a clock (PSWriteColor issue #15)

Parameters

-BackgroundColor Object[] optional
Background colour per piece.
-Color Object[] optional
Foreground colour per piece.
-Complete SwitchParameter optional
Writes the final version of the line and ends it.
-Decoration String[] optional
Decorations: Bold, Dim, Italic, Underline, Strikethrough, Invert.
-Markup String optional
Markup added after the pieces.
-Role ThemeToken optional
A theme role for pieces without their own colour.
Possible values: Text, Muted, Subtle, Accent, Accent2, Pass, Fail, Warn, Info, Skip, Running, Pending, Border, Title, Header, Highlight, Surface, SurfaceAccent, Series1, Series2, Series3, Series4, Series5, Series6, Focus
-ShowElapsed SwitchParameter optional
Shows the time since the status line started.
-ShowTimestamp SwitchParameter optional
Shows the time of day, refreshed every second.
-Spinner SwitchParameter optional
Shows a spinner while the status is open.
-Status StatusKind optional
A status marker before the text (Pass, Fail, Warn, Info, Running...).
Possible values: Pending, Running, Pass, Fail, Warn, Skip, Info
-Text Object[] optionalposition: 0
Text pieces, shown literally (strings, or rich text from New-ConsoleText).
-TimestampFormat String optional
The clock format (default HH:mm:ss).

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.