I’m trying to wrap my head around the right way to use the Command Line submitter to run Powershell scripts in such a way that they can properly report task progress. I have a dummy script for testing that simply writes out the expected STDOUT:
for ($i=1;$i -le 10;$i++){
$msg = ("Progress: " + [string]($i*10) + "%")
#Write-Output $msg --doesn't work
Write-Host $msg
#without the following line all the updates are written at once on completion
[Console]::Out.Flush()
Start-Sleep -Seconds 7}
The only way I’ve found where the progress bar in Monitor actually updates is
Execute in Shell: True
Shell to Use: cmd
and then supplying the powershell executable path as the first argument and my script as the second argument.
It seems odd to run a shell within a shell to do this, and it’s making wonder if I should just redefine one of the UNIX shells as Powershell in the submitter repo options instead. The absence of a canned Powershell option seems to suggest this is a bad idea for reasons unknown however.
What’s best practice for running Powershell scripts through deadline while having them able to write their execution progress to the progress bar in Monitor?