VMware Cloud Community
atfrys
Hot Shot
Hot Shot

Some powershell scripts output is null even though the script runs with no errors

I am seeing behavior when executing scripts using invoke-vmscript from a shared powershell session that I get null from the output from time to time, but not always.  Strange that the powershell executes without errors, but the result that is supposed to return does not.  If I run it from the powershell host, it returns output. I am thinking it could be memory related.  I got around of some of it by opening new powershell sessions for those workflows.  Has anyone seen this?

Thank you

0 Kudos
5 Replies
igaydajiev
VMware Employee
VMware Employee

The output of ps script execution  will be available approximately for 3 minutes after the session is closed.

I would not relay on this behavior but rather will preserve the data I need before closing the PS session. By preserve I mean copy field values in variables of vCO system type like string, number or properties. Otherwise PS plugin is preserving the data for 3 minutes after closeSession is invoked and data are cleaned.

If session is not provided when making PS calls using PowerShell plugin session is created explicitly by the plugin and closed after the call completes.

Another approach can be to control when the session is opened and closed.

1. Open session

2. Invoke PS script in specific session

3. Use output results

3. Close session

Hope It helps,

Ivo

0 Kudos
atfrys
Hot Shot
Hot Shot

Thank you for the response.  I open one powershell session at the beginning and close it at the end.  The powershell scripts execute correctly, but the output is null.  On some of the workflows that are failing, I put a local open session and close session and that seems to help, but slows down my workflow because I have to keep opening up new sessions.

Thank you

0 Kudos
atfrys
Hot Shot
Hot Shot

Session Workflow A - Opens Session -->Workflow B executes a powershell command and has a result (string).  Workflow C executes a different powershell command and has the same output variable called result and so on.  Maybe I should have a unique result output variable? Maybe they are stepping on each other, but I would expect some value?  I would not understand why that would happen.

Thank you

0 Kudos
igaydajiev
VMware Employee
VMware Employee

Could you attach sample workflow?

0 Kudos
atfrys
Hot Shot
Hot Shot

Turns out I needed more shells and processes per shell set in the winrm quota.  Not sure why VCO did not show the error in the workflow as I spit out all errors in my output.  It just showed up null.  I ran the same command from my powershell host and it barked at me about me exceeding my quota.

Thank you

0 Kudos