weird delay of the output of an object when followed by start-sleep (or until script end)
问题 For some reason, the object won't output until the sleep command is done. [pscustomobject]@{message = 'hi'}; sleep 5 Here's another example. You won't see the output until the loop finishes. foreach ($i in 1..60) { if ($i -eq 1) { [pscustomobject]@{message = $i} } sleep 1 } I guess you have to output at least 2 objects to see anything? ¯\_(ツ)_/¯ After 15 seconds, you see both objects. foreach ($i in 1..60) { if ($i -eq 1 -or $i -eq 15) { [pscustomobject]@{message = $i} } sleep 1 } Or output