title: Reset Powershell Form after User Submits Request
body: <p>How can I get a form to reset/close after the user has successfully submitted their request? I'm testing using Powershell ise and the script never closes until I actually X out. Here are my current functions.</p>
  
  <p>My form is working like it should thanks to the folks on this forum. I have another issue I'm struggling with. How do I get the form to reset after the user hits the submit button? I currenlty have to exit out of the form for the script to end.</p>
  
  <pre><code>#region gui events {
  $btn1.Add_Click({ sendRequest; thankyou })
  #endregion events }
  
  #endregion GUI }
  function sendRequest()
  {
      # API Key
      $FDApiKey="api key"
      #################################################
  
      # Force TLS1.2 as Powershell defaults to TLS 1.0 and Freshdesk will fail connections 
      [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12
  
      # Prep
      $pair = "$($FDApiKey):$($FDApiKey)"
      $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
      $base64 = [System.Convert]::ToBase64String($bytes)
      $basicAuthValue = "Basic $base64"
      $FDHeaders = @{ Authorization = $basicAuthValue }
      ##################################################
  
      $Body = @{
          description = $description.Text
          email = $email.Text
          subject = $subject.Text
          type = $request.Text
          priority = 1
          status = 2
      }
  
      Invoke-WebRequest "https://clasd.freshdesk.com/api/v2/tickets/" `
          -Headers $FDHeaders `
          -ContentType "application/json" `
          -Method Post `
          -Body ($Body | ConvertTo-JSON)
  }
  
  function thankyou ()
  {
      [System.Windows.Forms.MessageBox]::Show("Your ticket has been submitted!" , "Status") 
  }
  
  #Write your logic code here
  
  [void]$Form.ShowDialog()
  </code></pre>