Skip to content

Instantly share code, notes, and snippets.

@jdhitsolutions
Last active November 19, 2024 17:19
Show Gist options
  • Save jdhitsolutions/bcabd96b500e34a7ee5188edda2a632f to your computer and use it in GitHub Desktop.
Save jdhitsolutions/bcabd96b500e34a7ee5188edda2a632f to your computer and use it in GitHub Desktop.
A custom PowerShell view for history items. This requires PowerShell 7.
<!--
history.format.ps1xml
Format type data generated 11/19/2024 11:19:23 by PROSPERO\Jeff
This file was created using the New-PSFormatXML command that is part
of the PSScriptTools module.
https://github.com/jdhitsolutions/PSScriptTools
To use, import this file into your PowerSHell 7 session:
Update-FormatData -appendPath c:\scripts\history.format.ps1xml
Then use it by specifying the custom view
Get-History -count 10 | Format-Table -view time
-->
<Configuration>
<ViewDefinitions>
<View>
<!--Created 11/19/2024 11:19:23 by PROSPERO\Jeff-->
<Name>time</Name>
<ViewSelectedBy>
<TypeName>Microsoft.PowerShell.Commands.HistoryInfo</TypeName>
</ViewSelectedBy>
<TableControl>
<!--Delete the AutoSize node if you want to use the defined widths.
<AutoSize />-->
<TableHeaders>
<TableColumnHeader>
<Label>Time</Label>
<Width>20</Width>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Duration</Label>
<Width>11</Width>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>CommandLine</Label>
<Width>41</Width>
<Alignment>left</Alignment>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<ScriptBlock>
"{0:g}" -f $_.EndExecutionTime
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
"$($PSStyle.Italic+$PSStyle.Foreground.BrightYellow){0:mm\:ss\:ffff}$($PSStyle.Reset)" -f $_.Duration
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>CommandLine</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>You don't understand! I could've had class. I could've been a contender. I could've been somebody, instead of a bum, which is what I am.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment