Add-ConsoleItem
Adds items to a console widget made earlier: tree nodes, pairs, status items, bars, series, log lines, lanes or values.
Syntax
Add-ConsoleItem -InputObject <PSObject> [-Item] <Object> [-KeyProperty <String>] [-PassThru] [<CommonParameters>]#All Parameter SetsDescription
Adds items to a console widget made earlier: tree nodes, pairs, status items, bars, series, log lines, lanes or values.
The PowerShell way to grow a widget after it was created, instead of calling its .NET methods. Pipe the widget in and give the items as a script block or values; they are the same item commands the widget's own script block takes: New-ConsoleTreeNode for New-ConsoleTree, New-ConsoleKeyValueItem for New-ConsoleKeyValue, New-ConsoleStatusItem for New-ConsoleStatusList and New-ConsolePhases, New-ConsoleBarItem for New-ConsoleBarChart, New-ConsoleChartSeries for New-ConsoleLineChart, New-ConsoleLogEntry for New-ConsoleLog and New-ConsoleLane for New-ConsoleLanes. Sparklines and histograms take numbers, a cell map takes status words, and a live table takes objects or hashtables with a property per column. -PassThru writes the widget on, so it can go straight to Write-ConsoleWidget. For a widget inside a running dashboard, use the live commands (Add-ConsoleValue, Set-ConsoleValue, Update-ConsoleStatus, Write-ConsoleLog...) instead.
Examples
EXAMPLE 1
$log = New-ConsoleLog -Height 5
$log | Add-ConsoleItem { New-ConsoleLogEntry 'Discovered 4 domain controllers' -At 2s }
$log | Add-ConsoleItem { New-ConsoleLogEntry 'DC02 lags by 42 minutes' -Level Warning -At 31s }
$log | Write-ConsoleWidgetAdd log lines as the script goes, then show the log
EXAMPLE 2
$tree = New-ConsoleTree 'Shares'
foreach ($share in Get-SmbShare) {
$tree | Add-ConsoleItem { New-ConsoleTreeNode $share.Name -Detail $share.Path }
}
$tree | Write-ConsoleWidgetGrow a tree in a loop
EXAMPLE 3
New-ConsoleSparkline -Label 'req/s' | Add-ConsoleItem 3, 5, 8, 13, 9 -PassThru | Write-ConsoleWidgetValues for a sparkline, written on
Parameters
- -InputObject PSObject
- The widget to add to (pipeline input): a tree or tree node, key/value list, status list, phases, bar chart, stacked bar, line chart, log, lanes, cell map, sparkline, histogram or live table.
- -Item Object
- The items: a script block that emits them, or the items themselves.
- -KeyProperty String
- For a live table: the property whose value is the row key (default the first column).
- -PassThru SwitchParameter
- Writes the widget to the pipeline after adding.
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.