0

I run the iex alias on my computer everything looks good (it executes the command inside and print output into PS console), eg: iex "c:\windows\system32\inetsrv\appcmd list apppool /xml"

enter image description here

But if I run this on a server, it opens a cmd windows with results and leave PS console empty, I expect result be printed in PS console.

Do you know if this could be some settings differences ? Anyidea to fix is much appriciated !

hazjack
  • 1,645
  • 13
  • 27
  • Why would you need `Invoke-Expression` at all, here? Why not just execute the command directly? If you actually want to use the results, you can assign them to a variable directly: `$x = [xml] (c:\windows\System32\inetsrv\appcmd.exe list apppool /xml)`. – Jeroen Mostert Oct 31 '19 at 10:17
  • I execute this remotely, from other server, via octopus. – hazjack Oct 31 '19 at 11:33
  • That doesn't really explain why `Invoke-Expression` is necessary. Presumably Octopus just runs the command locally over a remoted connection, since `Invoke-Expression` doesn't support remoting (that's `Invoke-Command`). – Jeroen Mostert Oct 31 '19 at 11:37
  • @JeroenMostert yes I have same feeling but its in a package which works on other servers except one, will have to look on the details to have an answer – hazjack Nov 01 '19 at 07:39

0 Answers0