Add-Type -AssemblyName system.windows.Forms 
 
$Form = New-Object -TypeName windows.forms.form 
$Form.Text = 'Ma première Form' 
$Form.Size = New-Object System.Drawing.Size(400, 150) 
 
$ButtonOk = New-Object System.Windows.Forms.Button 
$ButtonOk.Text = 'OK' 
$ButtonOk.Size = New-Object System.Drawing.Size(100, 30) 
$ButtonOk.Location = New-Object System.Drawing.Size(150, 80) 
$ButtonOk.Add_CLick( 
    { 
        $TextBox = New-Object -TypeName System.Windows.Forms.TextBox 
        $TextBox.Text = 'Hello World' 
        $TextBox.Size = New-Object System.Drawing.Size(100, 20) 
        $TextBox.Location = New-Object System.Drawing.Size(150, 60) 
        $Form.Controls.Add($TextBox) 
 
        $ButtonOk.Text = 'Quitter' 
        $ButtonOk.Add_CLick( {$Form.Close()}) 
    } 
) 
$Form.Controls.Add($ButtonOk) 
 
#Création de l'objet Menu 
$Menu = New-Object System.Windows.Forms.MenuStrip 
 
#Création des éléments 
$ElementPrin = New-Object Sys-tem.Windows.Forms.ToolStripMenuItem('ElementPrin') 
$Element1 = New-Object System.Windows.Forms.ToolStripMenuItem('Element1') 
$Element2 = New-Object System.Windows.Forms.ToolStripMenuItem('Element2') 
$Element2a = New-Object Sys-tem.Windows.Forms.ToolStripMenuItem('Element2a') 
$Element2b = New-Object Sys-tem.Windows.Forms.ToolStripMenuItem('Element2b') 
 
#Ajout des éléments au menu 
[void]$elementPrin.DropDownItems.add($element1) 
[void]$elementPrin.DropDownItems.add($element2) 
[void]$element2.DropDownItems.add($element2a) 
[void]$element2.DropDownItems.add($element2b) 
[void]$Menu.Items.Add($ElementPrin) 
 
#Ajout du menu à la Form 
[void]$Form.Controls.Add($Menu) 
 
$Form.ShowDialog()
