2

Within my Powershell session, the word job is recognized as an "invokable action":

PS C:\Users\Rene\> job
 
Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
1      Job1            BackgroundJob   Completed     True            localhost            ...
3      Job3            BackgroundJob   Completed     True            localhost            ...
5      Job5            BackgroundJob   Completed     True            localhost            ...
7      Job7            BackgroundJob   Completed     True            localhost            ... 
9      Job9            BackgroundJob   Completed     True            localhost            ...

The output of job is the same as of get-job. So, I assumed that job is a function or an alias or a cmdLet. Yet, this does not seem to be the case:

PS C:\Users\Rene> get-command job
get-command : The term 'job' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.

So, if job is neither a cmdlet nor function, nor alias, nor script file, what is it?

5
  • You are not showing what code you are using. There are variables that get created, (automatic on Powershell startup and session, when code is executed - locally or remotely), and typing a cmdlet, function, object or variable, will show output. You should check for stuff that is automatic and session, then compare to get the difference. You have to trap all the automatic stuff on launch each time to make sure you have a valid compare. The base test is a type job only when jobs are active, then kill all jobs, clear all job objects, and type it again.
    – postanote
    Sep 16, 2020 at 22:30
  • PoSh parses the commands it sees by checking the literal PS command, then the command with get- as a prefix, then it looks along the OS search path for that literal command [bat/cmd/exe]. [grin] so what you are seeing is as-designed - it is running the ThingTypedIn with a Get- prefix.
    – Lee_Dailey
    Sep 16, 2020 at 23:24
  • Yeppers, forgot to add that piece. good follow-up my virtual-PS-fellow-old-IT-dude. ;-}.
    – postanote
    Sep 17, 2020 at 3:04
  • @Lee_Dailey please turn your comment into an answer so that I can mark this question as solved. BTW, is this documented somewhere? Sep 17, 2020 at 18:32
  • @RenéNyffenegger - done! [grin] please let me know how to improve it. what i have posted seems ... incomplete and rather rough.
    – Lee_Dailey
    Sep 17, 2020 at 23:54

1 Answer 1

1

You have run into how Powershell decides what you intend to run. For what happens, here is what I have been told, or have seen:

When you enter a command, PS looks for...

  • the exact command you have entered
  • for the exact command in the OS path listing(s)
  • the command with Get- prefixed to it

That sequence matches what I recall of what I have read or experienced, but I may have left out a step or two.

While I have never found any official documentation on this, several folks over at Reddit's Powershell subreddit have posted about it over the last few years. I presume that one could dig into the Powershell GitHub code and find the process, but I have never done so.

I also presume that any PS-focused code golf site would also have some ideas on what all is involved.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .