I am creating a powershell script as a background job using start-job which then logs it's output using start-transcript. Below is the code of both:
a
start-job -filepath ./b.ps1 -ArgumentList 'test.txt'
wait-job *
b
param([parameter(Mandatory = $true)][string]$logfile)
Set-PSDebug -Strict
$ErrorActionPreference = 'Stop'
start-transcript $logfile
output of ./a.ps1
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
1 Job1 Running True localhost param...
1 Job1 Failed False localhost param...
2 Job2 Failed False localhost param...
Output of ./b.ps1 -log c:\test.txt
Transcript started, output file is test.txt
Transcript stopped, output file is C:\test.txt
I have also done some testing by setting "echo here" lines to confirm that is the line playing up.