Need Help With Forms and DialogResult

<p class="_1qeIAgB0cPwnLhDF9XSiJM">Hi y’all, I’m not too familiar with PS outside of using it for program cmdlets so I’m in need of a bit of guidance.</p>
<p class="_1qeIAgB0cPwnLhDF9XSiJM">I frankensteined a script to create a form for a user to select a radio button, enter information into a text box, and when the OK button is hit to use that info to search for a specific file on a share. That portion works as intended, hoorah.</p>
<p class="_1qeIAgB0cPwnLhDF9XSiJM">Problem is, I don’t want the dialog to close after the OK button is clicked. I know it has to do with the button being set as the AcceptButton and the whole dialogresult bit, but everything I’ve tried to do with Add_Click to circumvent that hasn’t worked either. The pastebin of the script is below if you’d like to offer some advice.</p>
<p class="_1qeIAgB0cPwnLhDF9XSiJM">Thanks in advance.</p>

The script is basically executing line by line, so the code is just checking if the result is ok and then it finishes. Take a look at the code from Dan Potter in this post, which is generated from Sapien’s Powershell Studio. When the button is clicked, it is executing a function using a event (_Click), so the script would not exit.

You can also take a look at WPF:

With WPF you can use Visual Studio Express (free) to generate the form and then just wire it into Powershell.