PSMetrics.format.ps1xml
<?xml version="1.0" encoding="utf-16"?> <!-- Generated with EZOut 1.9.9: Install-Module EZOut or https://github.com/StartAutomating/EZOut --> <Configuration> <ViewDefinitions> <View> <Name>Chart</Name> <ViewSelectedBy> <TypeName>Chart</TypeName> </ViewSelectedBy> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock> if (-not $global:ChartEngine) { $global:ChartEngine = 'ChartJS' } $_ | Format-Custom -View $global:ChartEngine | Out-String -Width 1mb </ScriptBlock> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </View> <View> <Name>ChartJS</Name> <ViewSelectedBy> <TypeName>Chart</TypeName> </ViewSelectedBy> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock> $chartInfo = $_ $ChartName = $_.MetricName $chartLabels = @() $chartData = @() foreach ($row in $chartInfo.ChartData) { $firstProp, $secondProp, $rest = @($row.psobject.properties) $chartLabels += $firstProp.Value $chartData += $secondProp.value } $chartHTMLID = $ChartName -replace '[\s\p{P}\<\>]' $chartType = if ($chartInfo.ChartType) { $chartInfo.ChartType } else { 'bar' } @" $( if ($chartInfo.Metadata.Count) { @( "---" foreach ($kv in $chartInfo.Metadata.GetEnumerator()) { "$($kv.Key): $(if ($kv.Value -is [string] -or $kv.Value.GetType().IsPrimitive) { $kv.Value } else {ConvertTo-Json $kv.Value -Compress})" } "---" ) -join [Environment]::NewLine } ) <div style='width:100%;height:100%;text-align:center;justify-content:center'> <div style='max-height:90%;display:flex;margin-left:auto;margin-right:auto;text-align:center;justify-content:center'> <canvas id="$chartHTMLID"></canvas> </div> </div> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script> const ctx = document.getElementById('$chartHTMLID'); new Chart(ctx, { type: '$chartType', data: { labels: $($chartLabels | ConvertTo-Json -Compress), datasets: [{ label: '$ChartName', data: $($chartData | ConvertTo-Json -Compress), borderWidth: 1 }] } }); </script> "@ </ScriptBlock> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </View> <View> <Name>PowerShellUniversal</Name> <ViewSelectedBy> <TypeName>Chart</TypeName> </ViewSelectedBy> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock> $chartInfo = $_ $ChartName = $_.MetricName $chartLabels = @() $chartData = @() foreach ($row in $chartInfo.ChartData) { $firstProp, $secondProp, $rest = @($row.psobject.properties) break } $chartHTMLID = $ChartName -replace '[\s\p{P}\<\>]' $chartType = if ($chartInfo.ChartType) { $chartInfo.ChartType } else { 'bar' } "New-UDChartJS -Data ( ConvertFrom-JSON '$((ConvertTo-Json -Compress -InputObject $chartInfo.ChartData) -replace "'","''")' ) -Type $chartType -Id $chartHTMLID -DataProperty '$($secondProp.Name)' -LabelProperty '$($firstProp.Name)'" </ScriptBlock> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </View> <View> <Name>Metric</Name> <ViewSelectedBy> <TypeName>Metric</TypeName> </ViewSelectedBy> <TableControl> <TableHeaders> <TableColumnHeader> </TableColumnHeader> <TableColumnHeader> </TableColumnHeader> <TableColumnHeader> <Label>InputProperties</Label> </TableColumnHeader> </TableHeaders> <TableRowEntries> <TableRowEntry> <Wrap /> <TableColumnItems> <TableColumnItem> <PropertyName>MetricName</PropertyName> </TableColumnItem> <TableColumnItem> <PropertyName>Synopsis</PropertyName> </TableColumnItem> <TableColumnItem> <ScriptBlock> $_.InputProperties -join [Environment]::NewLine </ScriptBlock> </TableColumnItem> </TableColumnItems> </TableRowEntry> </TableRowEntries> </TableControl> </View> </ViewDefinitions> </Configuration> |