Regarding - Invoke-PSUScript

Product: PowerShell Universal
Version: 3.1.4

Ref: https://github.com/ironmansoftware/issues/issues/1374

@adam Thanks for applying the fixes to Invoke-PSUScript in 3.1.4.
With the latest version I don’t see the Object reference error now.

However, when ‘-Wait -Integrated’ parameters are used I unable to forward the messages in Child script to the Parent script logging yet. Is this something you would expect with the revised fix. Screenshot below for reference.

My objective is to have all the logs written to Parent job regardless of the task is performed by Parent / Child job as it would help us to have the capability to audit / review the log in a single place instead of jumping back and forth between different jobs. I hope its possible with ‘-Wait -Integrated’ parameter, but no luck yet.

Script to re-produce the issue

Parent script :

It all starts with a single line of powershell code.

Write-Host ‘Begin Parent job…’

Invoke-PSUScript -Name TestScript.ps1 -Wait -Integrated

Write-Host ‘Completed Parent job…’

Child script : TestScript.ps1

It all starts with a single line of powershell code.

param
(

)

write-host “Begin executing Child script…”

Start-Sleep -Seconds 10

write-host “Completed Child script…”

Current output

Can you double check that your script is not set to -InformationAction SilentlyContinue? I noticed that my scripts were and once I changed that, it was forwarding output.

Appreciate your quick help !!

After including the ‘-InformationAction “Continue”’ parameter, I now see the messages coming to the Parent job. In addition to that, the message were also written to the child Job as well. Is this an expected behavior ? The child message sent to parent job does meet my requirement. In addition to that, the child job was created with messages associated with the child process, just checking if this is an expected behavior.

Invoke-PSUScript -Name TestScript.ps1 -Wait -Integrated -InformationAction “Continue”

This is all expected behavior. If you want to avoid the child jobs all together, you can just call the PS1 files from the parent job.

Write-Host ‘Begin Parent job…’
& "$PSScriptRoot\TestScript.ps1"
Write-Host ‘Completed Parent job…’

Appreciate the suggestion.