Run job as a function?

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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 6 years and 6 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
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Run job as a function?

Post by stevens »

$jobresult = receive-job -Name GroupMemberSearch is showing output during debug, but $jobresult is empty.
In att. the new form. Thanks for you any input.
Attachments
Retrieve-GroupsAsaJob-V3.psf
(28.99 KiB) Downloaded 111 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Run job as a function?

Post by jvierra »

You cannot really successfully debug a job that is being accessed asynchronously in a timer event.

As I noted much earlier. Your function cannot and will not return anything from a job that it starts. Forget the function. It is just making this much harder for you to understand.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Run job as a function?

Post by jvierra »

stevens wrote: Tue Sep 26, 2017 5:57 am Thanks, but can't you just point out where I'm wrong in my script?
I have pointed this out a number of times. I cannot help you understand this. You need to stop, go back and learn the basics or how PowerShell and forms work. You are still guessing at most things.

There is a new book by the designer of PS and an excellent co-author. It starts from the basic concepts and carefully and clearly explains the how and why of each part of PowerShell. You should get a copy and sit down and carefully read it being sure you understand each paragraph before moving to the next one. Do not attempt to skip things you think you know.

https://www.amazon.com/Windows-PowerShe ... 1633430294
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Run job as a function?

Post by stevens »

Got version 2 of that in pdf, will print it and go through it. To bad though you wouldn't help me figuring out the function.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Run job as a function?

Post by jvierra »

Do not use The second edition get The third edition as the second version is pretty much misleading for all versions of PS post PS V2 (V3-V5.1). The most important thing is to be sure you understand each step before moving on. Test each idea in PowerSHell until you are sure you understand.

For new programmers this is critical. Once you become proficient in any language then you will be able to move faster.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Run job as a function?

Post by stevens »

Note: already read "Manning PowerShell in Depth 2nd (2015)" but honestly didn't worked with PS when I read it.
Appreciate your input and will act upon your advise. Ordered the book V3, will be there next week.
This topic is 6 years and 6 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