0

Trying to run an command-line executable from within a PowerShell script, unfortunately the current limitation is the host running only version 2.

The command runs fine, however it appears to only be partial output that is added to the variable, and just by chance the most important information is being missed. Is there anyway to capture everything into the output?

$output = Invoke-Expression ($itemCommand)
Write-Output $output

Testing on v3 and v4 works just fine, in fact was able to get away without using $output.

Anyone know if it is possible to have a portable copy of PowerShell v3 or v4 on a host running v2?

  • 2
    Not without knowing what it runs. Are you sure you aren't trying to capture a message from `write-host` or something like that? – Frode F. Mar 14 '16 at 06:15
  • And no, there's nothing called Portable PowerShell. PowerShell is a windows component that's built into the OS. – Frode F. Mar 14 '16 at 07:05
  • I am creating a log of the PowerShell script session using transcription. The command that is called gives a results table, yet the transcription is not capturing this - even though it does displays in the console. I note that it actually does the same thing with v3 and v4 using $output, if I do a straight Invoke-Expression it works - if I do that with v2 it outputs nothing. – JeffreyN Mar 14 '16 at 09:03
  • Unless you are using WinXp you can upgrade the version of PS that comes in Windows to PS 3 or 4. – Χpẘ Mar 15 '16 at 02:08
  • Thanks, I think that may be my only option. It has been communicated but unlikely to happen as the servers in question are rather mission critical. – JeffreyN Mar 17 '16 at 02:44

0 Answers0