Invoke-Item with Jobs

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

Re: Invoke-Item with Jobs

Post by jvierra »

I still cannot figure out what you are trying to do here.

If you use Test-Path it will tell you if a folder is valid and it is fast. What all of the rest is for makes little sense.

Why use a workflow or job when you just want to test a number of folder paths??? Test-Path is nearly instantaneous.
User avatar
StillLearning
Posts: 39
Last visit: Tue Apr 10, 2018 9:39 pm

Re: Invoke-Item with Jobs

Post by StillLearning »

Let’s start over.

I’m attempting to make a button to open an explorer window. This folder is the backup of a users data.

I know the username but I don’t know which server it resides on.

I’d like to loop through my list of servers in a txt file and find the users folder

I also don’t want it to freeze my form.

Workflow in a job would be the wiset solution to my problem I believe.
Last edited by StillLearning on Tue Mar 13, 2018 9:40 pm, edited 1 time in total.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Invoke-Item with Jobs

Post by jvierra »

Why do you need Invoke-Itgem to find a folder. Just use the test=path command in a llop and break the loop when the folder is found.

if(Test-Path $path){ break}
User avatar
StillLearning
Posts: 39
Last visit: Tue Apr 10, 2018 9:39 pm

Re: Invoke-Item with Jobs

Post by StillLearning »

I want to view the folder contents so I can check for errors hence my invoke-item

The errors are easier to identify browsing the folder due to no error logging from our data capture application.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Invoke-Item with Jobs

Post by jvierra »

What? I do not understand. How does this help?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Invoke-Item with Jobs

Post by jvierra »

Just return all files found from the workflow then open them in Explorer.
User avatar
StillLearning
Posts: 39
Last visit: Tue Apr 10, 2018 9:39 pm

Re: Invoke-Item with Jobs

Post by StillLearning »

Good morning!

It’s not the files I want to open but the users folder in explorer

\\server13\datacapture\jvierra

This is why I have to do a test-path in a foreach loop
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Invoke-Item with Jobs

Post by jvierra »

I still can't understand what the issue is. It opens every folder that it finds. That is what you workflow does. What is it you want it to do?
User avatar
StillLearning
Posts: 39
Last visit: Tue Apr 10, 2018 9:39 pm

Re: Invoke-Item with Jobs

Post by StillLearning »

Yes! We’re now on the same page. Earlier you asked why I did that and it had me confused as it made me think I was doing it incorrectly.

So now, is there a way to stop the job when it finds the folder? I’ll obviously have to figure how to do something in the complete section of the job tracker, maybe by finding the new process?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Invoke-Item with Jobs

Post by jvierra »

Stopping a workflow job is not possible due to timing. It will not stop fast enough to get only one.

You need to change your design. Return the folders that are found as they are found. Use the UpdateScript to open the first one returned and ignore all others.

You could use the update to fill a listbox with the results and use the listbox event to open the first insert and ignore all other inserts.

Many ways to do this but you cannot open explorer from the job.
This topic is 6 years and 1 month 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