Have found two examples of Invoke-Command in PS MOL 2nd ed. where the example includes -parameters that aren’t native for the cmdlet. In other words, they don’t list out via Intellisense, yet they do work:
pg 251
Invoke-Command -command
and
pg 252
Invoke-Command {} -session
Neither -command nor -session are listed automatically via intellisense. -Command I think is a positional parameter and is not explicitly required however -session IS required if I want to pass my $session content.
Please help me to understand these particular flavors of parameters.
The -Session parameter does exist on Invoke-Command, so you should be seeing it in intellisense. -Command, on the other hand, was renamed to -ScriptBlock later on, to be more consistent with other similar cmdlets such as Start-Job and Register-ObjectEvent, etc. There is still a -Command alias for -ScriptBlock, for backward compatibility. It’ll still tab-complete, but aliases don’t show up in Intellisense.
“The -Session parameter does exist on Invoke-Command, so you should be seeing it in intellisense”
I only see “-SessionName” and “-SessionOption” populating via Intellisense and they won’t work with an actual session id I have in a variable. I have to use only “-session” (as the book demonstrates)
I don’t know what to tell you. If I’m in the ise and I type “Invoke-Command -”, to start Intellisense, -Session is the very first thing in the list for me.
The example in the book uses a {} scriptblock before the parameter switch. So, yes, if I simply omit the script block I do get intellisense to populate the simple -session parameter.
What prompted my initial question is the example as illustrated in the book.