0

When I run following command on powershell window (version 5.1)

(Get-Service *someServiceName*).status

I get output in 3 columns as follows:

PSComputerName RunspaceId Value
-------------- ---------- -----
xxxxx           xxxxxx    Running

On the other hand, when I run following command on same powershell window:

powershell -command "(Get-Service *someServiceName*).status"

I get following output:

Running

Please note that I am running above commands through remote conenction.

Why is it so ? why the output format is different in the two cases though we are running the same command. what could be the issue ? On most of the machines, the two kinds of command always behave in similar way, but this is not the case on my machine. Why ?

Vishwanath
  • 149
  • 2
  • 14
  • 1
    your 1st example indicates that you are running it in a remote call. those 1st 2 props are what you get from using something like `Invoke-Command` to run stuff remotely. the 2nd example is the actual _bare_ output of the command. – Lee_Dailey Jul 23 '21 at 07:48
  • but even if we run the second command in invoke-command, we get output as "Running" only. – Vishwanath Jul 23 '21 at 07:54
  • 1
    the `RunspaceId` property name is from using a runspace of some sort. **_when i run the code you have posted, i do not get the 1st result - i get the 2nd result for both of your code snippets._** that means you are **_doing something different_** from what you have shown. – Lee_Dailey Jul 23 '21 at 08:33
  • edited the question to mention that the commands were run remotely. Could you please tell why the commands behave differently when both the commands are run remotely ? – Vishwanath Jul 23 '21 at 09:01
  • 1
    please, show the EXACT CODE required to get the results you are showing. _the current examples DO NOT produce the results you show._ – Lee_Dailey Jul 23 '21 at 09:29

0 Answers0