I'd like to see the "live" output of an application when I call it.
When I call it in a function, it works properly, as if I would call it directly. I can cancel the application with Ctrl+C and the "progress bar" the application outputs is updated:
function Test()
{
dism.exe /online /Cleanup-Image /AnalyzeComponentStore
}
Test
[=== 5.5% ]
When I call it in a method however, there is no output visible.
I can work around that by writing & dism.exe /online /Cleanup-Image /AnalyzeComponentStore 2>&1 | Write-Host
but for this example, it would not update the progress bar but instead write a new line whenever there's a progress update:
class TestC
{
Test()
{
& dism.exe /online /Cleanup-Image /AnalyzeComponentStore 2>&1 | Write-Host
}
}
$testC = [TestC]::new()
$testC.Test()
[= 3.3% ]
[=== 5.5% ]
I also cannot cancel the application with Ctrl+C, instead only the script would be cancelled and the called application continues in the background.
Is there an explanation for this? And a working workaround? :)
Thank you!