I experienced a very weird behavior when I execute a PowerShell script. I want to run a sub-command of the `tf` command. This executable usually works as a console application, but the sub-command `tf resolve` command displays a dialog, which I want to see.

Can some PowerShell Guru please explain me, what's going on in Use case 1b & 2b? Or do you have a hint what's the problem here?

*Remarks:* Please modify the VS version according to your installation, if it is not found. I'm using VS 2015, PowerShell 4, Windows 8.1.

**Use case 1a:**
Dialog is displayed (Everything is okay)

```
$tfCommand = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\tf.exe"
& $tfCommand resolve

```

**Use case 1b:**
Dialog is NOT displayed (WTF?!)

*Changes:* The STDOUT is saved in a variable

```
$tfCommand = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\tf.exe"
$someVariable = & $tfCommand resolve

```

**Use case 2a:**
Dialog is displayed (Everything is okay)

```
$tfCommand = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\tf.exe"

function callTfResolve($tfCommand) { 
   & $tfCommand resolve 
}

CallTfResolve $tfCommand

```

**Use case 2b:**
Dialog is NOT displayed (WTF?!)

*Changes:* Return value of `CallTfResolve` is saved in a variable

```
$tfCommand = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\tf.exe"

function callTfResolve($tfCommand) { 
   & $tfCommand resolve 
}

$someVariable = CallTfResolve $tfCommand

```