Use .NET in PowerShell script

Print
[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object Windows.Forms.Form
$form.Text = "My first form"
$button = New-Object Windows.Forms.Button
$button.text="Click here!"
$button.Dock="fill"
$button.add_click({$form.close()})
$form.controls.add($button)
$form.Add_Shown({$form.Activate()})
$form.ShowDialog()

 

This website uses cookies to ensure you get the best experience on our website.