Powershell progressbar not showing if convert in exe

Viewed 908

If I execute the script in the console the progress bar is shown perfectly, but if I convert the script to exe with ps2exe the progress bar is not shown.

How can I solve this issue? Thank you

$totalTimes = 10
$i = 0

for ($i=0;$i -lt $totalTimes; $i++) {
   $percentComplete = ($i / $totalTimes) * 100
   Write-Progress -Activity 'Doing thing' -Status "Did thing $i  times" -PercentComplete $percentComplete
   sleep 1
}
1 Answers

Have you tried with PS2EXE-GUI?

It "converts" PowerShell scripts to EXE Files, optionally as GUI applications:

.\ps2exe.ps1 -noconsole -inputFile 'test.ps1' -outputFile 'test.exe' 

If test.ps1 contains your sample code, running .\test.exe will show a GUI progress bar such as the following:

enter image description here

Related