profesorfalken / jPowerShell

Simple Java API to interact with PowerShell console
Apache License 2.0
217 stars 84 forks source link

Output of command is returned when calling $? #66

Open JUGI4U opened 5 years ago

JUGI4U commented 5 years ago

Please check this sequence of commands: *Get-Process $? Get-Process | Format-List $?**

The first Get-Process and $? work as expected. But the second call of Get-Process returns an empty response. However its result (or at least part of it) is returned when calling $? afterwards.

It seems that Format-List * seems to make trouble. When I start the command with PS_ISE, it works as expected.

BTW: The same applies when replacing $? with $error.

Sample output:

Execute command: Get-Process Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName


436 22 7708 23476 1,83 12944 1 ABC
488 28 30316 34532 3,06 11408 1 XYZ...

Execute command: $? True

Execute command: Get-Process | Format-List *

Execute command: $? Name : ABC Id : 12944...