Showing the output of a function within PowerShell
When a function within PowerShell returns a value, Write-Output for example doesn’t show the output to your console. The reason for this is that Write-Output redirects it output to the output stream and this is in returned by the function.
To solve this, you can use for example Write-Host or more specialized output redirects like Write-Debug.
Showing the output of a batch file within a function
When executing a batch file within a PowerShell script like this
&myBatchFile.cmd
something similar happens. The output of the command file will also be redirected to the output of the function. However, you can’t use here the Write-Host. Instead of that, you can use the following to show the output within your console window:
&myBatchFile.cmd | Out-Host
The Out-Host redirects the output generated by the batch file to the command line.