New-ConsoleLogEntry
Creates one log line with a level and a time, for New-ConsoleLog.
Syntax
New-ConsoleLogEntry [-At <TimeSpan>] [-Level <String>] [-Message] <Object> [<CommonParameters>]#All Parameter SetsDescription
Creates one log line with a level and a time, for New-ConsoleLog.
Use it inside the script block of New-ConsoleLog to show a log printed once, or pipe a log made earlier to Add-ConsoleItem with these entries. -Level takes info, warn, err, verbose, debug, pass or skip, or PowerShell's words (Information, Warning, Error, Verbose, Debug, Success, Skipped). -At is the time shown at the start of the line: a TimeSpan, a number of seconds, or a number with a unit (500ms, 2s, 1.5m, 1h). The message is shown literally; rich text from New-ConsoleText keeps its colours. In a running dashboard, write to the log with Write-ConsoleLog instead.
Examples
EXAMPLE 1
New-ConsoleLog -Height 5 {
New-ConsoleLogEntry 'Discovered 4 domain controllers in 2 domains' -Level Info -At 2s
New-ConsoleLogEntry 'DC02: replication partner DC05 last success 3h ago' -Level Warning -At 31s
New-ConsoleLogEntry 'DC02: USN rollback check failed (event 2095)' -Level Error -At 44s
} | Write-ConsoleWidgetA short log printed once
EXAMPLE 2
$events = Import-Csv deploy-events.csv
New-ConsoleLog {
foreach ($event in $events) { New-ConsoleLogEntry $event.Message -Level $event.Level -At $event.Seconds }
} | Write-ConsoleWidgetEntries from objects
Parameters
- -At TimeSpan
- The time shown at the start of the line: a TimeSpan, seconds (2 or 1.5) or a number with a unit (500ms, 2s, 1.5m, 1h). Default 0.
- -Level String
- The level: info, warn, err, verbose, debug, pass or skip, or PowerShell's words (Information, Warning, Error, Verbose, Debug, Success, Skipped). Default info.
- -Message Object
- The message (shown literally; rich text from New-ConsoleText keeps its colours).
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.