If you are like me and have multiple machines you work on with different profiles, it can be difficult to remember which profile contains which functions. So, I wrote a quick function that will display all the functions for me on start up.
Just add the code below to the bottom of your $profile file.
Function Get-ProfileFunctions {
$__ProfileFunctions = Get-Content $profile | Where-Object { $_.Trim() -match '^function' } | Foreach-Object {
$_.Replace('{', ' ').Replace('(', ' ').Split()[1]
}
if ($__ProfileFunctions) {
Write-Host "Profile functions loaded`n$('-' * 24)" -ForegroundColor Yellow
$__ProfileFunctions | ForEach-Object { Write-Host " - $($_)" -ForegroundColor Yellow }
Write-Host "`n"
}
}
Get-ProfileFunctions
Now when you open PowerShell you will see a prompt like the one below showing you the functions you have in the profile file.
Profile functions loaded ------------------------ - MyCustom-Function1 - Get-ProfileFunctions
You can also run Get-ProfileFunctions at any time to show the functions again.