0

I was missing a return statement in the code, not a PowerShell problem.

Thanks for all the good comments anyway!

Aaron S.
  • 1
  • 2
  • Whether output succeeds is unrelated to the complexity of a script, so the problem must lie elsewhere (we'll have to wait till you post your code, ideally in the form of an [MCVE (Minimal, Complete, and Verifiable Example)](http://stackoverflow.com/help/mcve)); also note that `Write-Output` and `Write-Host` serve very different purposes. – mklement0 Sep 12 '18 at 16:31
  • Share the sample code please – Ranadip Dutta Sep 12 '18 at 16:43
  • 1
    Possible duplicate of [Which should I use: "Write-Host", "Write-Output", or "\[console\]::WriteLine"?](https://stackoverflow.com/questions/8755497/which-should-i-use-write-host-write-output-or-consolewriteline) – Bacon Bits Sep 12 '18 at 17:06
  • If you haven't got a specific question with your specific code you're having trouble with, then all I can suggest is that you take the time to learn about the PowerShell pipeline and the difference between `Write-Output` (which outputs to the pipeline/stdout) and `Write-Host` (which writes text to the console but does not use an output stream). – Bacon Bits Sep 12 '18 at 17:11
  • There's another decent explanation [here](https://www.itprotoday.com/management-mobility/write-output-or-write-host-powershell). – Bacon Bits Sep 12 '18 at 17:13
  • I am aware of the different ways output is handled. I actually need to push it through the pipeline because I monitor the pipeline with a C# program. Unfortunately, I was missing a return statement in my script and so the variable was always an empty string and so I didn't get any value. Rookie mistake I guess, thanks anyway for your help! Also thanks for your links @BaconBits they helped me to understand the concept of the pipeline better. – Aaron S. Sep 13 '18 at 04:14

0 Answers0