Show-ConsoleStatusLine
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>]#All Parameter SetsDescription
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 -CompleteA 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 -CompleteA waiting line with a clock (PSWriteColor issue #15)
Parameters
- -BackgroundColor Object[]
- Background colour per piece.
- -Color Object[]
- Foreground colour per piece.
- -Complete SwitchParameter
- Writes the final version of the line and ends it.
- -Decoration String[]
- Decorations: Bold, Dim, Italic, Underline, Strikethrough, Invert.
- -Markup String
- Markup added after the pieces.
- -Role ThemeToken
- 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
- Shows the time since the status line started.
- -ShowTimestamp SwitchParameter
- Shows the time of day, refreshed every second.
- -Spinner SwitchParameter
- Shows a spinner while the status is open.
- -Status StatusKind
- A status marker before the text (Pass, Fail, Warn, Info, Running...).
- Possible values:
Pending,Running,Pass,Fail,Warn,Skip,Info - -Text Object[]
- Text pieces, shown literally (strings, or rich text from New-ConsoleText).
- -TimestampFormat String
- 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.