Skip to content

Instantly share code, notes, and snippets.

@devblackops
Created June 13, 2019 23:07
Show Gist options
  • Save devblackops/9cbfb88d426426e6a45cab724a9a2a27 to your computer and use it in GitHub Desktop.
Save devblackops/9cbfb88d426426e6a45cab724a9a2a27 to your computer and use it in GitHub Desktop.
Get your most common PowerShell commands by inspecting your PSReadLine history
$err=$null
[System.Management.Automation.PSParser]::Tokenize((Get-Content (Get-PSReadLineOption).HistorySavePath),[ref]$err) |
Where-Object {$_.type -eq 'command'} |
Select-Object Content | Group-Object Content |
Sort-Object Count, Name -Descending | Select-Object Count, Name -First 20
@KirkMunro
Copy link

@vexx32 Your script gives me completely different (inaccurate) results. The one at the top works properly.

@vexx32
Copy link

vexx32 commented Jun 14, 2019

Yeah, it does. Interesting.

Problem for another day! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment