In doing some Powershell automation, I'm having trouble with the way that data written to stdout by a .cmd file is automatically captured. I have two functions that do something like the following:

function a {
    & external.cmd # prints "foo"
    return "bar"
}

function b {
    $val = a
    echo $val # prints "foobar", rather than just "bar"
}

Basically, data that external.cmd sends to stdout is added to the return value of a, even though all I really want to return from a is the string that I specified. How can I prevent this?

Edit
Report