Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing # Create form $form = New-Object System.Windows.Forms.Form $form.Text = "Password Generator" $form.Size = New-Object System.Drawing.Size(400,200) $form.StartPosition = "CenterScreen" $form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog $form.MaximizeBox = $false # Create label $label = New-Object System.Windows.Forms.Label $label.Location = New-Object System.Drawing.Point(10,20) $label.Size = New-Object System.Drawing.Size(380,20) $label.Text = "Click the 'Generate Password' button to generate a new password:" $form.Controls.Add($label) # Create button $button = New-Object System.Windows.Forms.Button $button.Location = New-Object System.Drawing.Point(130,60) $button.Size = New-Object System.Drawing.Size(140,40) $button.Text = "Generate Password" $button.Add_Click({ $length = 10 # Password length $characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%+-=" $password = "" for ($i=0; $i -lt $length; $i++) { $index = Get-Random -Minimum 0 -Maximum $characters.Length $password += $characters[$index] } Set-Clipboard "$password" [System.Windows.Forms.MessageBox]::Show($password, "Generated Password") }) $form.Controls.Add($button) # Show form $form.ShowDialog() | Out-Null