Created
June 13, 2019 23:07
-
-
Save devblackops/9cbfb88d426426e6a45cab724a9a2a27 to your computer and use it in GitHub Desktop.
Get your most common PowerShell commands by inspecting your PSReadLine history
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |
@vexx32 Your script gives me completely different (inaccurate) results. The one at the top works properly.
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
PSParser is ancient and doesn't handle things well; use
System.Management.Automation.Parser.ParseInput()
instead: