Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janikvonrotz/10965567 to your computer and use it in GitHub Desktop.
Save janikvonrotz/10965567 to your computer and use it in GitHub Desktop.
PowerShell: Create alphabetical sorted list of all functions #PowerShell #PowerUp
cls
$B = "https://github.com/janikvonrotz/PowerShell-PowerUp/blob/master/functions/"
$A = "H:/SkyDrive/Shared/Projects/GitHub/Powershell-PowerUp/functions/"
$Terms = Get-ChildItem $PSfunctions.Path -Recurse -Filter *.ps1 |
select Name, BaseName, @{L="Verb";E={$_.Name.Split("-")[0]}},@{L="Noun";E={$_.BaseName.Split("-")[1]}}, FullName, @{L="Url";E={$_.FullName -replace "\\","/" -replace $A,$B}} |
Sort-Object Noun, Verb
$OutPut = @()
$HeadingWraper = "<h1 id=`"%`"><a href=`"#index`">%</a></h1>"
$OutPut += "<h1 id=`"index`">Index</h1>"
$OutPut += (
[char[]]([int][char]'A'..[int][char]'Z') | ForEach-Object{
if($_ -ne 'Z'){
"<a href=`"#$("$_".tolower())`"> $_ </a>|"
}else{
"<a href=`"#$("$_".tolower())`"> $_ </a>"
}
}
)
$OutPut += "</p>"
[char[]]([int][char]'A'..[int][char]'Z')| ForEach-Object{
$OutPut += $HeadingWraper -replace "%", $_
$Char = $_
$TermsOutput = $Terms | Where-Object{$_.Noun.Startswith($Char)}
if(-not $TermsOutput){
$OutPut += "<p>-</p>"
}else{
$OutPut += "<p>" + ($TermsOutput | ForEach-Object{
if(-not ($_ -eq $TermsOutput[0])){
"<br/>`n<a href='$($_.Url)'>$($_.BaseName)</a>"
}else{
"`n<a href='$($_.Url)'>$($_.BaseName)</a>"
}
}) + "</p>"
}
}
$OutPut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment