Created
February 2, 2021 10:03
-
-
Save tjgruber/0a2121b4c785b7f844d2d2aed1fbb0d1 to your computer and use it in GitHub Desktop.
Iron Scripter - Scripting Challenge Meetup
This file contains 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
$helpTopic = "about_Splatting" | |
$excludedWords = "the" | |
$words = ((Get-Help $helpTopic) -replace "[^\w]"," " -replace "\d"," " -replace '_'," " -split " ") | Where-Object {$_ -ne ""} | |
$sortedWords = $words | Group-Object | Sort-Object -Property Count -Descending | Where-Object -Property Name -NE $excludedWords | |
[PSCustomObject]@{ | |
'Help Topic Name' = $helpTopic | |
'Word Count' = $words.Count | |
'Top Word' = ($sortedWords | Select-Object -First 1).Name | |
'Top Word Count' = ($sortedWords | Select-Object -First 1).Count | |
'Top 5 Words' = ($sortedWords | Select-Object -First 5).Name -join ", " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OUTPUT: (IronScripter-ScriptingChallengeMeetup.ps1)
Just to verify my word count is close:
(Get-Help $helpTopic | Measure-Object -Word).Words
Output: