working in Windows 11 with PowerShell 7.5.1 (NOT Windows PowerShell)
i have some functions and aliases defined in
C:\Users\Jeff\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
here are the definitions
Function envvar { param ([string]$varname) gci env`:$varname }
new-alias -name envvar -value envvar
new-alias -name testvar -value envvar
in a new PS window i do command Get-Alias to see the list of defined aliases and mine is in the list
Alias envvar -> envvar
but when i do command envvar PATH i get this:
PS C:\Users\Jeff> envvar PATH
envvar: The term 'envvar' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
[general]
The most similar commands are:
> envvar
so maybe the problem is that i used the same name for the alias and the function, but no:
PS C:\Users\Jeff> testvar PATH
testvar: The term 'testvar' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Users\Jeff>
i have not found a way to list user defined functions so i cant tell if the function is correctly defined .. but i suspect not
my goal is to have a PS command that can return a (formatted, or at least split) list of the elements in one of the paths PATH, LIB, or LIBPATH
new-alias -name envvar -value envvaryou're overwriting the function with an alias that points to nowhere...