Trying to make gui for input

Welcome Forums General PowerShell Q&A Trying to make gui for input

Viewing 2 reply threads
  • Author
    • #207375
      Topics: 1
      Replies: 0
      Points: 12
      Rank: Member

      I am trying o makeĀ  this command in to a GUI.

      <p class=”x_MsoNormal”>Get-WmiObject -Class win32_computersystem -ComputerName 10.XXX.XX.XX | select username</p>
      My desired result is to type the IP in the GUI and the out put would be the username who is logged in.

      I have my GUI set up but I am not sure how to put in the command. I am bew to powershell so forgive me for ignornace.

      # Load the Winforms assembly
      [reflection.assembly]::LoadWithPartialName( "System.Windows.Forms")
      # Create the form
      $form = New-Object Windows.Forms.Form
      #Set the dialog title
      $form.text = "Find User"
      # Create the label control and set text, size and location
      $label = New-Object Windows.Forms.Label
      $label.Location = New-Object Drawing.Point 50,30
      $label.Size = New-Object Drawing.Point 200,15
      $label.text = "Enter IP Address"
      # Create TextBox and set text, size and location
      $textfield = New-Object Windows.Forms.TextBox
      $textfield.Location = New-Object Drawing.Point 50,60
      $textfield.Size = New-Object Drawing.Point 200,30
      # Create Button and set text and location
      $button = New-Object Windows.Forms.Button
      $button.text = "Find User"
      $button.Location = New-Object Drawing.Point 100,90
      {Get-WmiObject -Class win32_computersystem -ComputerName 10.XXX.XX.XX | select username


    • #207378
      Topics: 6
      Replies: 93
      Points: 427
      Helping Hand
      Rank: Contributor

      You are almost there (untested):

      $button.Add_Click({$textfield.Text = Get-WmiObject -Class win32_computersystem -ComputerName 10.XXX.XX.XX | select username})

      • This reply was modified 2 months, 3 weeks ago by TonyD05.
    • #207822
      Topics: 1
      Replies: 3
      Points: 21
      Rank: Member

      There is missing




Viewing 2 reply threads
  • You must be logged in to reply to this topic.