PowerShell: long lines in Get-History

If I just save my history thus…

get-history | clip

, then I find beyond 80 characters whatever, you get truncation (note the ellipses):


Outputting to json helps…

Get-History | ConvertTo-Json

, but it is still a bit of a hunt to find what you want:


First, we will get the history into an array of strings, splitting on Newline:


$history = Get-History | ConvertTo-Json
$historyLines = $history -split [System.Environment]::Newline

From the previous screenshot, I am only interested in those lines which contain [CommandLine]:

$historyLines | % {if ($_ -match "CommandLine") { $_ }}


But I want to exclude the repeated “CommandLine” etc. For now, I’ll just cheat. I found that the start of the variable part is at offset 25, so I’ll just do this for now:

$historyLines | % {if ($_ -match "CommandLine") {$_.substring(25, $_.length - (25+2)) }}

, which gives this, which is good enough for now:


Finally, bringing the 3 lines together:

$history = Get-History | ConvertTo-Json
$historyLines = $history -split [System.Environment]::Newline
$historyLines | % {if ($_ -match "CommandLine") {$_.substring(25, $_.length - (25+2)) }}


Aliases, plus other ways to get the full history

h | Format-List -Property *
h | Format-List -Property CommandLine
h -id 31 -Count 10
h -id 31 -Count 10 | fl
h | fl -Property CommandLine | clip


Rulers of England since 1066

I am an avid watcher of University Challenge. I am appalled that I cannot routinely sequence names, dates and houses for English rulers. This site is pretty good, including these mnemonics:


This is a useful site for converting plain text to html tables
Dates Ruler House
1066-1087 William I Normandy
1087-1100 William II Normandy
1100-1135 Henry I Normandy
1135-1154 Stephen Blois
1154-1189 Henry II Angevin
1189-1199 Richard I Angevin
1199-1216 John Angevin
1216-1272 Henry III Plantagenet
1272-1307 Edward I Plantagenet
1307-1327 Edward II Plantagenet
1327-1377 Edward III Plantagenet
1377-1399 Richard II Plantagenet
1399-1413 Henry IV Lancaster
1413-1422 Henry V Lancaster
1422-1461 Henry VI Lancaster
1461-1483 Edward IV York
1483 Edward V York
1483-1485 Richard III York
1485-1509 Henry VII Tudor
1509-1547 Henry VIII Tudor
1547-1553 Edward VI Tudor
1553-1558 Mary I Tudor
1558-1603 Elizabeth I Tudor
1603-1625 James I Stuart
1625-1649 Charles I Stuart
1649-1653 Commonwealth Commonwealth
1653-1658 Oliver Cromwell (Lord Protector) Commonwealth
1658-1659 Richard Cromwell (Lord Protector) Commonwealth
1660-1685 Charles II Stuart
1685-1688 James II Stuart
1689-1694 William III of Orange and Mary II Orange
1694-1702 William III Orange
1702-1714 Anne Stuart
1714-1727 George I Hanover
1727-1760 George II Hanover
1760-1820 George III Hanover
1820-1830 George IV Hanover
1830-1837 William IV Hanover
1837-1901 Victoria Hanover
1901-1910 Edward VII Saxe-Coburg-Gotha
1910-1936 George V Windsor
1936 Edward VIII Windsor
1936-1952 George VI Windsor
1952- Elizabeth II Windsor