From 1951d95ceb121f6d0addc371969af64f8faa334d Mon Sep 17 00:00:00 2001 From: Bobban Date: Tue, 11 Apr 2023 04:59:16 +0200 Subject: [PATCH] pwassword generate script --- PowerShell/Password-generator.ps1 | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 PowerShell/Password-generator.ps1 diff --git a/PowerShell/Password-generator.ps1 b/PowerShell/Password-generator.ps1 new file mode 100644 index 0000000..8042066 --- /dev/null +++ b/PowerShell/Password-generator.ps1 @@ -0,0 +1,38 @@ +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 \ No newline at end of file