ironmansoftware / powershell-universal

Issue tracker for PowerShell Universal
https://powershelluniversal.com
37 stars 4 forks source link

Invoke-PSUScript no longer waiting for pipeline output #2777

Closed kp-bit closed 1 year ago

kp-bit commented 1 year ago

Version

4.1.6

Severity

Critical

Steps to Reproduce

We have several dashboards utilizing scripts to search in AD, Azure, CosmosDB, etc., and returning whatever found to a table or autocomplete. This has been working like a charm until yesterday, where PowerShell 7.3.8 was installed on the servers. Now Invoke-PSUScript no longer waits for the pipeline (we're using -Wait of course, and the scripts run in Integrated context).

I can see in the Jobs list that the scripts run as expected and return data, but in the dashboard we get the error "Object reference not set to an instance of an object" immediately - and not after the script has finished.

Has the installation of PowerShell 7 broken some integration and would the fix be to reinstall PSU?

Expected behavior

Invoke-PSUScript -Wait waiting for pipeline output

Actual behavior

Invoke-PSUScript -Wait immediately failing

Additional Environment data

PowerShell 7 was not installed at all on the servers before.

Visuals

No response

adamdriscoll commented 1 year ago

@kp-bit I can reproduce this too. Did you only upgrade PS yesterday? What persistence method are you using? I'm currently seeing it when using LiteDB but haven't tried other types.

kp-bit commented 1 year ago

Using LiteDB as well, also fiddled with Az.Account versions as PowerShell 5.x didn't want to connect with anything newer than 2.12.1 (known bug), which is why PS 7 was installed. But scripts are running fine so I don't suspect any modules here.

adamdriscoll commented 1 year ago

Ok. I just tried with SQL and that works fine so it's something with the LiteDB integration...

I don't know how a PS7 upgrade would affect this, but I'll dig in and let you know.

kp-bit commented 1 year ago

Cheers, really appreciated!

adamdriscoll commented 1 year ago

@kp-bit Ok. I made a tweak that got this working again. I still don't totally understand why updating PS caused this but we had an implicit conversion going on that I changed to an explicit one and that fixed it. This will be included in tonight's nightly build if you would like to give it a shot as well. Just ping me if you still see it.

kp-bit commented 1 year ago

Okay, will install the nightly build tomorrow and report back...

adamdriscoll commented 1 year ago

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

https://forums.ironmansoftware.com/t/invoke-psuscript-not-passing-through-job-data/9874/4

kp-bit commented 1 year ago

Looks like the nightly build fixed it, thanks!