Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automation: Merge jobs #1374

Closed
arunrajann opened this issue Jul 16, 2022 · 10 comments
Closed

Automation: Merge jobs #1374

arunrajann opened this issue Jul 16, 2022 · 10 comments
Labels
completed The issue has been completed but is not yet released. enhancement New feature or request PowerShell Universal Issue relates to PowerShell Universal.

Comments

@arunrajann
Copy link

Summary of the new feature / enhancement

When a script is called / triggered from another script using 'Invoke-PSUScript', the PSU is creating a new / separate job for the child. I am sure there is a good reason why this design pattern is implemented. It becomes a little harder to analyze the log information created by the individual script as we have to jump back and forth between multiple jobs. It would `be great if we have an option to treat them as one integral job and log all the information in one job.

Invoke-PSUScript -Name DataExtract.ps1 -SourceSystemHostName $_SourceSystemHostName -SourceDatabaseName $_SourceDatabaseName

Proposed technical implementation details (optional)

Add a Parameter to 'Invoke-PSUScript' Cmdlet to treat them as one job / not to create a new job.

@arunrajann arunrajann added enhancement New feature or request PowerShell Universal Issue relates to PowerShell Universal. labels Jul 16, 2022
@adamdriscoll
Copy link
Member

You could effectively do this by using -Wait. It would bring the errors, warnings and output from the other script into the calling script.

@arunrajann
Copy link
Author

Appreciate looking into this request. Below are my current finding with sample script to simulate the issue

Based on my observation, messages are still written to the child job, in addition to that a error message 'Object reference not set to an instance of an object' is written to output when -Wait parameter is used but the system does wait until the child process is complete. I was hoping if there is a way to run just one job. At the least if the log-messages were written to parent job that would be great. No idea why we receive a object reference issue, am I missing something ?

Version : 3.1.0

Parent script

  Write-Host 'Begin Parent job...'       
  $output = Invoke-PSUScript -Name TestScript.ps1 -Wait      
  Write-Host 'Completed Parent job...' 

Child Script

      param(
      )          
      write-host "Begin executing Child script..."          
      Start-Sleep -Seconds 20

Parent Job output

image

Child job output

image

@adamdriscoll
Copy link
Member

This shouldn't be happening. Let me try to reproduce this.

@adamdriscoll
Copy link
Member

Can you try to use integrated mode? I just put together an integration test for this that works so this may be a workaround.

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

@arunrajann
Copy link
Author

No luck. Screenshot below for reference...

image

image

image

image

@adamdriscoll
Copy link
Member

@arunrajann - Can you let me know what version you are using?

@arunrajann
Copy link
Author

Version : 3.1.0 (2653491244)

Downloaded from the main download page on 7/12/2022.

@arunrajann
Copy link
Author

arunrajann commented Jul 19, 2022

Below is reference from another Team member in the community who received an error when -Wait parameter is used.

I could use ' | Wait-PSUJob ' to make the parent process to wait until the child process is complete... However, using it does not write the message / merge the child job with Parent which is what I was hoping to accomplish.

https://forums.ironmansoftware.com/t/invoke-psuscript-object-error/7296

@adamdriscoll
Copy link
Member

I have reproduced this and it will be fixed in 3.1.4

@adamdriscoll adamdriscoll added the completed The issue has been completed but is not yet released. label Jul 19, 2022
@adamdriscoll
Copy link
Member

This issue has been mentioned on Ironman Software Forums. There might be relevant details there:

https://forums.ironmansoftware.com/t/regarding-invoke-psuscript/7419/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed The issue has been completed but is not yet released. enhancement New feature or request PowerShell Universal Issue relates to PowerShell Universal.
Projects
None yet
Development

No branches or pull requests

2 participants