Get-ProfileFunctions.ps1


Description

Get-ProfileFunctions inventories the functions stored in your local profile repository and prints them in neatly padded columns. It expects a root folder of C:\GitRepos\ProfileFunctions, reads every .ps1 file beneath ProfileFunctions, plus the main Microsoft.PowerShell_profile.ps1, and uses helper commands like Get-ScriptFunctionNames and Invoke-BatchArray to format the output.

Usage examples

Get-ProfileFunctions

Ensure that Get-ScriptFunctionNames, Invoke-BatchArray, and Set-ConsoleConfig from the module are available in your session and that the profile path matches the structure assumed in the script.


Script

function Get-ProfileFunctions {
    $psPath = "C:\GitRepos\ProfileFunctions"
        $funcs = @();
        Get-ChildItem "$psPath\ProfileFunctions\*.ps1" |
                ForEach-Object {
                        $funcs = $funcs + (Get-ScriptFunctionNames -Path "$psPath\ProfileFunctions\$($_.Name)")
                }
        $funcs = $funcs + (Get-ScriptFunctionNames -Path "$psPath\Microsoft.PowerShell_profile.ps1")
        Invoke-BatchArray -Arr ($funcs | Sort-Object) -BatchSize 4 |
                ForEach-Object {
                        $line = ''
                        $_ | ForEach-Object {
                                $line += $_.PadRight(40, ' ')
                        }
                        Write-Host($line)
                }
}

Back to Top


Download

Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.


Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.

Issue


Back to Top