I have a 2 PS function that show certain processes and handles. I also have write-output command to show which is process and which are handles. How can prevent this write-output from popping up before the output of the function is ready to be shown ?
##Functions
# -------------------------------------------------------------------------------------------------------
function show-process($PName){
Write-Output "The running $PName processes are:"
Get-Process -Name $PName | select ProcessName, @{N='Session ID'; E={$_.SI}}, @{N='Process ID'; E={$_.ID}}, Handles
}
function show-handles($HPath){
Write-Output "Handles that have files open in $HPath : "
handle $HPath
}
# -------------------------------------------------------------------------------------------------------
##Start
# ------------------------------------------------------------------------------------------------------
show-process -PName $CLREXE
show-handles -HPath $CLRDIR
Currently i got this one: The write-output is shown at the right place. But it doesn't wait for the output from the function. It just displays the write-output as soon as press enter. But i want it to wait for the output and then display the write-output together with the function's output.