I’m learning power shell and stuck with the problem
I have test.ps1:
Test
Function Test
{
$a="a"
}
when I execute it from commandline:
PS > .\test.ps1
I get an error
The term 'Test' is not recognized as the name of a cmdlet, function,
but when I move call to the Test function after the declaration of the function, it works fine.
Is there a way to load all the functions from the script before the execution of the script?
It would be nice to keep the functions in the same file, after the main body of the script.
No, functions have to be declared first and called after that.
I don’t know any other language where it could be possible. But I can be mistaken.Consider this:
Now the main body as at the top as you’d like..