Skip to content

Instantly share code, notes, and snippets.

@thedavecarroll
Created February 1, 2021 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedavecarroll/3f85a4c5bb2d22f2ce7d44a7e2bddb48 to your computer and use it in GitHub Desktop.
Save thedavecarroll/3f85a4c5bb2d22f2ce7d44a7e2bddb48 to your computer and use it in GitHub Desktop.
Scripting Challenge Meetup
$Splatting = Get-Help about_Splatting
$SortByWordCount = $Splatting -Split('\W+') | Where-Object {$_ -ne 'the'} | Group-Object | Sort-Object -Property Count -Descending
$Splatting | Select-Object Name,
@{l='NumberOfWords';e={$_.ToString() | Measure-Object -Word | Select-Object -ExpandProperty Words}},
@{l='TopWord';e={$SortByWordCount[0].Name}},@{l='TopWordCount';e={$SortByWordCount[0].Count}},
@{l='Top5Words';e={($SortByWordCount.Name | Select-Object -First 5) -join ','}}
@thedavecarroll
Copy link
Author

Output:

Name          : about_Splatting
NumberOfWords : 1668
TopWord       : to
TopWordCount  : 54
Top5Words     : to,a,in,parameter,parameters

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