none
Powershell Script - pause until OK button pressed RRS feed

  • Question

  • I'm sorry if this is an obvious question - I'm no scripting expert but trying to get better!

    The problem I'm trying to solve is this.  We have users who use Microsoft Direct Access on the laptops / tablets we issue them.  Sometimes these users need to connect to a public WiFi hotspot, which requires them to accept terms and conditions / log in.  With a proxy set via Group Policy they're unable to reach that landing page unless they go into internet settings and disable the proxy.

    Currently they have access to do that - they shouldn't be able to though and I want to lock those setting down.

    The script I'm putting together uses powershell to disable the proxy, then they're presented with a dialog box telling them to go to the landing page and complete the connection.  Once done, they press OK, and the proxy is re-enabled.  All the proxy stuff in the script is working fine.

    I need to pause the script while the dialog is active, and not resume it until they've pressed ok.  Pressing OK sends a return code of 1 to powershell.  Currently, the script is just running all the way through to the end.

    I've found plenty of info online about pausing a script and waiting for a key stroke, but I'd much rather have a GUI dialog box presented to the users.  Does anyone have a method to do this?  Can I have powershell looping until it sees that return code appear?  Any hints much appreciated!

    • Moved by Bill_Stewart Friday, July 27, 2018 4:14 PM This is not "scripts on demand"
    Tuesday, April 17, 2018 12:16 AM

All replies

  • Yes you can have a dialog box that does almost anything you want.  And yes you can write a script that can wait on almost anything.

    Without a script or an error message there is little we can do beyond this to help you.

    The easiest way to bypass a defined proxy with a one time access is to add a route that accesses the resource you wish to enable.


    \_(ツ)_/

    Tuesday, April 17, 2018 12:29 AM
  • I'm sorry maybe I wasn't very clear.  The script is written, and it works, including the dialog box, I've got no problems with that.  The part I'm stuck on is how to script the logic that forces a pause until the OK button is pressed and the return code received.  There's all sorts of info online about pausing mid-script until a key is pressed, but I'm struggling to figure out how to script a pause that waits for the return code.
    Tuesday, April 17, 2018 12:33 AM
  • I'm sorry maybe I wasn't very clear.  The script is written, and it works, including the dialog box, I've got no problems with that.  The part I'm stuck on is how to script the logic that forces a pause until the OK button is pressed and the return code received.  There's all sorts of info online about pausing mid-script until a key is pressed, but I'm struggling to figure out how to script a pause that waits for the return code.

    Use a flag and set it in the Ok button.  Loop on the flag until it is set.  This will require a timer that synthesizes a loop.  On the timer tick dismiss if flag is not set else execute code.

    You cannot pause in a forms event.

    Again.  Without specific code there is no way to give a better answer.


    \_(ツ)_/

    Tuesday, April 17, 2018 12:38 AM
  • You would alos do better at finding solutions by posting in the Direct Access forum here: https://social.technet.microsoft.com/Forums/forefront/en-us/home?forum=forefrontedgeiag

    \_(ツ)_/

    Tuesday, April 17, 2018 12:39 AM