On Sep 25, 8:32 pm, "Hans Dingemans" <hans_dingem...@xxxxxx>
wrote:
> function get-ComRSS
> {
> param($param1)
>
> $param1
> $param1}
>
> comrss test1
>
> Why is it that the script above runs to completion without error?
>
> PS> c:/test
> test1
> test1
> PS>
>
> I would have expected that 'comrss' is not recognized as a cmdlet, function,
> etc.What's the logic behind this? There must be something special with the
> get verb. Changing comrss into abc throughout the script still does the job.
> Changing get- into something else requires the invocation to spell the
> function name out loud.
>
> I presume this is by design, but for what reason?
>
> Cheers,
> Hans
>
> PS: found a more elaborate sample in Payette's book, pages 408 and 409,
> using this "trick" and could not find easily why the function got invoked. You are right; this is by design. I don't know the exact details, but
during parsing, when a symbol comes up undefined, "get-" is added to
it to see if a match is found. This just makes more terse use of some
Cmdlets and functions automatic. You might think "help" is an alias
for the Cmdlet "Get-Help", but it isn't. You can check this by
running "Get-Alias help". PowerShell slaps a "get-" on the front when
a match for "help" isn't found, and you get what you want.
Jeff