title: Window form with button function powershell
body: <p>I have this function with "<strong>event handler</strong>" but I am unable in <strong>$event</strong> to define value in action section,</p>
  
  <pre><code>$event=Register-ObjectEvent $Button click -SourceIdentifier $clickV -action {write-host $buttonV }
  </code></pre>
  
  <p>I have the button but no output, see below with the function param,</p>
  
  <p>if I change my line with:</p>
  
  <pre><code>$event=Register-ObjectEvent $Button click -SourceIdentifier $clickV -action {write-host "OK"}
  </code></pre>
  
  <p>I have the button and the output</p>
  
  <p>Any help will be welcome,</p>
  
  <hr>
  
  <pre><code>Function Button
  {
      param(
          [int]$EmplXButton,
          [int]$EmplYButton,
          [innt]$LongButton,
          [int]$LargButton,
          [string]$ButtonName,
          [string]$clickV,
          [int]$ButtonV
      )
      $Button = New-Object System.Windows.Forms.Button
      $Button.Location = New-Object System.Drawing.Size($EmplXButton,$EmplYButton)
      $Button.Size = New-Object System.Drawing.Size($LongButton,$LargButton)
      $Button.Text = $ButtonName
      $event=Register-ObjectEvent $Button click -SourceIdentifier $clickV -action {
          write-host $buttonV ; Unregister-Event $clickV
      }
      $Button.Add_Click({$objForm.Close()})
      $objForm.Controls.Add($Button)
  }
  
  Button 20 60 90 23 zero clickV0 0
  Button 115 60 90 23 one clickV1 1
  Button 210 60 90 23 two clickV2 2
  Button 305 60 90 23 three clickV3 3
  #&gt;
  
  $objForm.Add_Shown({$objForm.Activate()})
  [void] $objForm.ShowDialog()
  </code></pre>