PSJob not running for v5 Host (silent)

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
PXL_Posh
Posts: 40
Joined: Wed Jan 10, 2018 9:37 am

PSJob not running for v5 Host (silent)

Post by PXL_Posh » Tue Jun 11, 2019 9:31 am

Product, version and build:
64 bit version of product: Powershell Studio 2019 v5.6.156
Operating system: 64 bit Windows 10 Enterprise

Using sychronized hashtable and xml with STA

The script will not generate the xml nor the csv.
In addition, I'm not seeing the additional window indicating the psjob is running.
I have plenty of error reporting but no errors are generated in the output window.

This runs without issue from ISE.
My settings are pretty basic:
no config file, no STA mode as that is already in the script, no impersonation nor runas.

I've tried all the Script Engines for v5 Host with the exception of service and Tray App.
issue_1.ps1
(3.91 KiB) Downloaded 64 times

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: PSJob not running for v5 Host (silent)

Post by davidc » Tue Jun 11, 2019 9:45 am

[TOPIC MOVED TO WINDOWS POWERSHELL FORUM BY MODERATOR]

I recommend selecting a console host to debug the executable. The silent host suppresses all output, including errors.
I addition, if you are doing any asynchronous operations, you much make sure you wait for the operation to complete otherwise the script will terminate when it gets to the end.
David
SAPIEN Technologies, Inc.

jvierra
Posts: 13992
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: PSJob not running for v5 Host (silent)

Post by jvierra » Tue Jun 11, 2019 9:56 am

This looks to be part of WPF code. Are you trying to call a function in a WPF form?

User avatar
PXL_Posh
Posts: 40
Joined: Wed Jan 10, 2018 9:37 am

Re: PSJob not running for v5 Host (silent)

Post by PXL_Posh » Tue Jun 11, 2019 10:17 am

Thank you for your reply davidc.

Unfortunately, I've tried a console host and nothing spits out. I tried again for the sake of testing and no errors.

I also ran the debug in powershell studio.

SAPIEN PowerShell V5 Host (Command line)

The receive-job has the -wait parameter which I hope is sufficient.

The script starts with "Please wait, contacting database..."
I've double checked the output window link and it matches correctly.

User avatar
PXL_Posh
Posts: 40
Joined: Wed Jan 10, 2018 9:37 am

Re: PSJob not running for v5 Host (silent)

Post by PXL_Posh » Tue Jun 11, 2019 10:17 am

jvierra wrote:
Tue Jun 11, 2019 9:56 am
This looks to be part of WPF code. Are you trying to call a function in a WPF form?
Yes, I am calling the fuction in a WPF form.

jvierra
Posts: 13992
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: PSJob not running for v5 Host (silent)

Post by jvierra » Tue Jun 11, 2019 10:54 am

I went through you code. In a couple of minutes I threw out almost half as redundant or incorrect.

I suggest that you test each piece of code without a form. Be sure that you remove all unnecessary lines and take advantage of good PS coding style and standards. This will make the code more predictable and much easier to understand.

Note that 'jobs" do not have a window or a display. If the thread that the job is running on terminates the job will disappear. Running a job in a delegate will fail because the delegate has limited access to the WPF form and the session that executed the delegate call. An "[action]" is a delegate. It is intended to trigger events and to set properties and is not intended as a remote function executor.

Looking at your code I find it very hard to understand what you are trying to accomplish and why it has to be run as a delegate.

Locked