Capture Output of "Deploy-Application.ps1"


I call the “Deploy-Application.ps1”-Script from another PowerShell-Script like this:

$PSADToolKit = Join-Path -Path $PSScriptRoot -ChildPath "MyApp\Deploy-Application.ps1"
& $PSADToolKit @Args

I want to:

  • Get the output on the screen
  • Save the output in a variable

I did try a lot of things, but I am still not able to capture the output in a variable.
For example I did try:

$Output = & $PSADToolKit @Args
$PSADToolKit @Args | Tee-Object -Variable Output

This does not work at all. The Variable is empty!?
If I try this with a simple PS1 it is working fine. It is not working with PSADTK and I don’t know why.

Any ideas?

Thank you!