PSJob not running for v5 Host (silent)

Ask your 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.
This topic is 4 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
PXL_Posh
Posts: 40
Last visit: Thu Nov 07, 2019 5:43 am

PSJob not running for v5 Host (silent)

Post by PXL_Posh »

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 210 times
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: PSJob not running for v5 Host (silent)

Post by davidc »

[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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PSJob not running for v5 Host (silent)

Post by jvierra »

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
Last visit: Thu Nov 07, 2019 5:43 am

Re: PSJob not running for v5 Host (silent)

Post by PXL_Posh »

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
Last visit: Thu Nov 07, 2019 5:43 am

Re: PSJob not running for v5 Host (silent)

Post by PXL_Posh »

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PSJob not running for v5 Host (silent)

Post by jvierra »

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.
This topic is 4 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked