1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678

<# .NOTES -------------------------------------------------------------------------------- Code generated by: https://poshgui.com/ and Powershell studio Generated on: 12/27/2017 2:57 AM Generated by: vKunal (http://vcloud-lab.com) Tested on : Windows 8.1, 10, Powershell v5 -------------------------------------------------------------------------------- .DESCRIPTION GUI script generated using https://poshgui.com/ and Powershell studio #> function New-RandomPasswordGUI { [void][reflection.assembly] :: Load( 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ) [void][reflection.assembly] :: Load( 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ) [void][reflection.assembly] :: Load( 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ) [System.Windows.Forms.Application] :: EnableVisualStyles() $formGenerateRandomPasswo = New-Object 'System.Windows.Forms.Form' $ErrorMessage = New-Object 'System.Windows.Forms.Label' $MessageResult = New-Object 'System.Windows.Forms.Label' $linklabelHttpvcloudlabcom = New-Object 'System.Windows.Forms.LinkLabel' $Result = New-Object 'System.Windows.Forms.Label' $NumberTextBox = New-Object 'System.Windows.Forms.TextBox' $SymbolTextBox = New-Object 'System.Windows.Forms.TextBox' $SmallTextBox = New-Object 'System.Windows.Forms.TextBox' $CapitalTextbox = New-Object 'System.Windows.Forms.TextBox' $checkboxNumber = New-Object 'System.Windows.Forms.CheckBox' $checkboxSymbol = New-Object 'System.Windows.Forms.CheckBox' $checkboxSmallNumber = New-Object 'System.Windows.Forms.CheckBox' $checkboxCapitalNumber = New-Object 'System.Windows.Forms.CheckBox' $GeneratePassword12 = New-Object 'System.Windows.Forms.Button' $groupbox1 = New-Object 'System.Windows.Forms.GroupBox' $SecondRadioButton = New-Object 'System.Windows.Forms.RadioButton' $groupbox2 = New-Object 'System.Windows.Forms.GroupBox' $labelPasswordLength = New-Object 'System.Windows.Forms.Label' $FirstRadioButton = New-Object 'System.Windows.Forms.RadioButton' $PasswordLength = New-Object 'System.Windows.Forms.TextBox' $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' $formGenerateRandomPasswo_Load ={ $ErrorMessage .Text = $null $MessageResult .Text = $null $FirstRadioButton .Checked = $true $PasswordLength .Text = 12 #Disable make your own password $checkboxCapitalNumber .Enabled = $false $checkboxSmallNumber .Enabled = $false $checkboxNumber .Enabled = $false $checkboxSymbol .Enabled = $false $CapitalTextbox .Enabled = $false $SmallTextBox .Enabled = $false $SymbolTextBox .Enabled = $false $NumberTextBox .Enabled = $false } $GeneratePassword12_Click ={ $RandomOption = @ () $CompletePassword = @ () $CompleteSmallPassword = @ () $CompleteCapitalPassword = @ () $CompleteSymbolPassword = @ () $CompleteNumberPassword = @ () #table $JSon = @" [ {"SrNo": "1","Number": "33","Character": "!","Phonetic": "Exclamation point","Type": "Symbol"}, {"SrNo": "2","Number": "34","Character": "\"","Phonetic": "Double quotes","Type": "Symbol"}, {"SrNo": "3","Number": "35","Character": "#","Phonetic": "Hash sign","Type": "Symbol"}, {"SrNo": "4","Number": "36","Character": "$","Phonetic": "Dollar sign","Type": "Symbol"}, {"SrNo": "5","Number": "37","Character": "%","Phonetic": "Percent sign","Type": "Symbol"}, {"SrNo": "6","Number": "38","Character": "&","Phonetic": "Ampersand","Type": "Symbol"}, {"SrNo": "7","Number": "39","Character": "'","Phonetic": "Single quote","Type": "Symbol"}, {"SrNo": "8","Number": "40","Character": "(","Phonetic": "Opening parenthesis","Type": "Symbol"}, {"SrNo": "9","Number": "41","Character": ")","Phonetic": "Closing parenthesis","Type": "Symbol"}, {"SrNo": "10","Number": "42","Character": "*","Phonetic": "Asterisk","Type": "Symbol"}, {"SrNo": "11","Number": "43","Character": "+","Phonetic": "Plus sign","Type": "Symbol"}, {"SrNo": "12","Number": "44","Character": ",","Phonetic": "Comma","Type": "Symbol"}, {"SrNo": "13","Number": "45","Character": "-","Phonetic": "Minus sign -Hyphen","Type": "Symbol"}, {"SrNo": "14","Number": "46","Character": ".","Phonetic": "Period","Type": "Symbol"}, {"SrNo": "15","Number": "47","Character": "/","Phonetic": "Slash","Type": "Symbol"}, {"SrNo": "16","Number": "58","Character": ":","Phonetic": "Colon","Type": "Symbol"}, {"SrNo": "17","Number": "59","Character": ";","Phonetic": "SemiColon","Type": "Symbol"}, {"SrNo": "18","Number": "60","Character": "<","Phonetic": "Less than sign","Type": "Symbol"}, {"SrNo": "19","Number": "61","Character": "=","Phonetic": "Equal sign","Type": "Symbol"}, {"SrNo": "20","Number": "62","Character": ">","Phonetic": "Greater than sign","Type": "Symbol"}, {"SrNo": "21","Number": "63","Character": "?","Phonetic": "Question mark","Type": "Symbol"}, {"SrNo": "22","Number": "64","Character": "@","Phonetic": "At symbol","Type": "Symbol"}, {"SrNo": "23","Number": "91","Character": "[","Phonetic": "Opening bracket","Type": "Symbol"}, {"SrNo": "24","Number": "92","Character": "\\","Phonetic": "Backslash","Type": "Symbol"}, {"SrNo": "25","Number": "93","Character": "]","Phonetic": "Closing bracket","Type": "Symbol"}, {"SrNo": "26","Number": "94","Character": "^","Phonetic": "Caret - circumflex","Type": "Symbol"}, {"SrNo": "27","Number": "95","Character": "_","Phonetic": "Underscore","Type": "Symbol"}, {"SrNo": "29","Number": "123","Character": "{","Phonetic": "Opening brace","Type": "Symbol"}, {"SrNo": "30","Number": "124","Character": "|","Phonetic": "Vertical bar","Type": "Symbol"}, {"SrNo": "31","Number": "125","Character": "}","Phonetic": "Closing brace","Type": "Symbol"}, {"SrNo": "32","Number": "126","Character": "~","Phonetic": "Equivalency sign - Tilde","Type": "Symbol"}, {"SrNo": "33","Number": "65","Character": "A","Phonetic": "Alpha ","Type": "Capital Letter"}, {"SrNo": "34","Number": "66","Character": "B","Phonetic": "Bravo ","Type": "Capital Letter"}, {"SrNo": "35","Number": "67","Character": "C","Phonetic": "Charlie ","Type": "Capital Letter"}, {"SrNo": "36","Number": "68","Character": "D","Phonetic": "Delta ","Type": "Capital Letter"}, {"SrNo": "37","Number": "69","Character": "E","Phonetic": "Echo ","Type": "Capital Letter"}, {"SrNo": "38","Number": "70","Character": "F","Phonetic": "Foxtrot ","Type": "Capital Letter"}, {"SrNo": "39","Number": "71","Character": "G","Phonetic": "Golf ","Type": "Capital Letter"}, {"SrNo": "40","Number": "72","Character": "H","Phonetic": "Hotel ","Type": "Capital Letter"}, {"SrNo": "41","Number": "73","Character": "I","Phonetic": "India ","Type": "Capital Letter"}, {"SrNo": "42","Number": "74","Character": "J","Phonetic": "Juliet ","Type": "Capital Letter"}, {"SrNo": "43","Number": "75","Character": "K","Phonetic": "Kilo ","Type": "Capital Letter"}, {"SrNo": "44","Number": "76","Character": "L","Phonetic": "Lima ","Type": "Capital Letter"}, {"SrNo": "45","Number": "77","Character": "M","Phonetic": "Mike ","Type": "Capital Letter"}, {"SrNo": "46","Number": "78","Character": "N","Phonetic": "November ","Type": "Capital Letter"}, {"SrNo": "47","Number": "79","Character": "O","Phonetic": "Oscar ","Type": "Capital Letter"}, {"SrNo": "48","Number": "80","Character": "P","Phonetic": "Papa ","Type": "Capital Letter"}, {"SrNo": "49","Number": "81","Character": "Q","Phonetic": "Quebec ","Type": "Capital Letter"}, {"SrNo": "50","Number": "82","Character": "R","Phonetic": "Romeo ","Type": "Capital Letter"}, {"SrNo": "51","Number": "83","Character": "S","Phonetic": "Sierra ","Type": "Capital Letter"}, {"SrNo": "52","Number": "84","Character": "T","Phonetic": "Tango ","Type": "Capital Letter"}, {"SrNo": "53","Number": "85","Character": "U","Phonetic": "Uniform ","Type": "Capital Letter"}, {"SrNo": "54","Number": "86","Character": "V","Phonetic": "Victor ","Type": "Capital Letter"}, {"SrNo": "55","Number": "87","Character": "W","Phonetic": "Whiskey ","Type": "Capital Letter"}, {"SrNo": "56","Number": "88","Character": "X","Phonetic": "X-Ray ","Type": "Capital Letter"}, {"SrNo": "57","Number": "89","Character": "Y","Phonetic": "Yankee ","Type": "Capital Letter"}, {"SrNo": "58","Number": "90","Character": "Z","Phonetic": "Zulu ","Type": "Capital Letter"}, {"SrNo": "59","Number": "97","Character": "a","Phonetic": "Alpha ","Type": "Small Letter"}, {"SrNo": "60","Number": "98","Character": "b","Phonetic": "Bravo ","Type": "Small Letter"}, {"SrNo": "61","Number": "99","Character": "c","Phonetic": "Charlie ","Type": "Small Letter"}, {"SrNo": "62","Number": "100","Character": "d","Phonetic": "Delta ","Type": "Small Letter"}, {"SrNo": "63","Number": "101","Character": "e","Phonetic": "Echo ","Type": "Small Letter"}, {"SrNo": "64","Number": "102","Character": "f","Phonetic": "Foxtrot ","Type": "Small Letter"}, {"SrNo": "65","Number": "103","Character": "g","Phonetic": "Golf ","Type": "Small Letter"}, {"SrNo": "66","Number": "104","Character": "h","Phonetic": "Hotel ","Type": "Small Letter"}, {"SrNo": "67","Number": "105","Character": "i","Phonetic": "India ","Type": "Small Letter"}, {"SrNo": "68","Number": "106","Character": "j","Phonetic": "Juliet ","Type": "Small Letter"}, {"SrNo": "69","Number": "107","Character": "k","Phonetic": "Kilo ","Type": "Small Letter"}, {"SrNo": "70","Number": "108","Character": "l","Phonetic": "Lima ","Type": "Small Letter"}, {"SrNo": "71","Number": "109","Character": "m","Phonetic": "Mike ","Type": "Small Letter"}, {"SrNo": "72","Number": "110","Character": "n","Phonetic": "November ","Type": "Small Letter"}, {"SrNo": "73","Number": "111","Character": "o","Phonetic": "Oscar ","Type": "Small Letter"}, {"SrNo": "74","Number": "112","Character": "p","Phonetic": "Papa ","Type": "Small Letter"}, {"SrNo": "75","Number": "113","Character": "q","Phonetic": "Quebec ","Type": "Small Letter"}, {"SrNo": "76","Number": "114","Character": "r","Phonetic": "Romeo ","Type": "Small Letter"}, {"SrNo": "77","Number": "115","Character": "s","Phonetic": "Sierra ","Type": "Small Letter"}, {"SrNo": "78","Number": "116","Character": "t","Phonetic": "Tango ","Type": "Small Letter"}, {"SrNo": "79","Number": "117","Character": "u","Phonetic": "Uniform ","Type": "Small Letter"}, {"SrNo": "80","Number": "118","Character": "v","Phonetic": "Victor ","Type": "Small Letter"}, {"SrNo": "81","Number": "119","Character": "w","Phonetic": "Whiskey ","Type": "Small Letter"}, {"SrNo": "82","Number": "120","Character": "x","Phonetic": "X-Ray ","Type": "Small Letter"}, {"SrNo": "83","Number": "121","Character": "y","Phonetic": "Yankee ","Type": "Small Letter"}, {"SrNo": "84","Number": "122","Character": "z","Phonetic": "Zulu ","Type": "Small Letter"}, {"SrNo": "85","Number": "48","Character": "0","Phonetic": "Zero","Type": "Number"}, {"SrNo": "86","Number": "49","Character": "1","Phonetic": "One","Type": "Number"}, {"SrNo": "87","Number": "50","Character": "2","Phonetic": "Two","Type": "Number"}, {"SrNo": "88","Number": "51","Character": "3","Phonetic": "Three","Type": "Number"}, {"SrNo": "89","Number": "52","Character": "4","Phonetic": "Four","Type": "Number"}, {"SrNo": "90","Number": "53","Character": "5","Phonetic": "Five","Type": "Number"}, {"SrNo": "91","Number": "54","Character": "6","Phonetic": "Six","Type": "Number"}, {"SrNo": "92","Number": "55","Character": "7","Phonetic": "Seven","Type": "Number"}, {"SrNo": "93","Number": "56","Character": "8","Phonetic": "Eight","Type": "Number"}, {"SrNo": "94","Number": "57","Character": "9","Phonetic": "Nine","Type": "Number"} ] "@ #Excluded Characters #{"SrNo": "28","Number": "96","Character": "`","Phonetic": "Grave accent","Type": "Symbol"}, #System.Security.Cryptography.RNGCryptoServiceProvider function Get-Rng { $RandomBytes = New-Object -TypeName "System.Byte[]" 4 $Random = New-Object -TypeName "System.Security.Cryptography.RNGCryptoServiceProvider" $Random .GetBytes( $RandomBytes ) [BitConverter] :: ToInt32( $RandomBytes , 0) } #function Get-Rng #tables $AlphbatesTable = $JSon | ConvertFrom-Json $SymbolTable = $AlphbatesTable | Where-Object { $_ .Type -eq 'Symbol' } $CapitalLetterTable = $AlphbatesTable | Where-Object { $_ .Type -eq 'Capital Letter' } $SmallLetterTable = $AlphbatesTable | Where-Object { $_ .Type -eq 'Small Letter' } $NumberTable = $AlphbatesTable | Where-Object { $_ .Type -eq 'Number' } #-or ($CapitalTextbox.Text -is [int]) -or ($SmallTextBox.Text -is [int]) -or ($SymbolTextBox.Text -is [int]) -or ($NumberTextBox -is [int]) if (( $FirstRadioButton .Checked -eq $true ) -and ( $SecondRadioButton .Checked -eq $false )) { $ErrorMessage .Text = $null if ( $PasswordLength .Text -match '[0-9]' ) { for ( $i = 1 ; $i -le $PasswordLength .Text ; $i ++) { $DefaultUniqueNumber = Get-Rng $PasswordHash = Get-Random -InputObject $AlphbatesTable -SetSeed $DefaultUniqueNumber $CompletePassword += $PasswordHash .Character $CompletePassword = $CompletePassword -join '' } #for ($i = 1; $i -le $PasswordLength; $i++) $ErrorMessage .Text = $null } else { $ErrorMessage .Text = "Type valid number in the Password Length Textbox" } } else { if ( $SmallTextBox -ne 0 -and $SmallTextBox .Text -match '[0-9]' -and $checkboxSmallNumber .Checked -eq $true ) { for ( $sm = 1 ; $sm -le $SmallTextBox .Text ; $sm ++) { $SmallUniqueNumber = Get-Rng $CompleteSmallPassword += Get-Random -InputObject $SmallLetterTable -SetSeed $SmallUniqueNumber } #for ($sm = 1; $sm -le $SmallLetter; $sm++) } #if ($SmallLetter -ne 0) if ( $CapitalTextBox -ne 0 -and $CapitalTextbox .Text -match '[0-9]' -and $checkboxCapitalNumber .Checked -eq $true ) { for ( $c = 1 ; $c -le $CapitalTextBox .Text ; $c ++) { $CapitalUniqueNumber = Get-Rng $CompleteCapitalPassword += Get-Random -InputObject $CapitalLetterTable -SetSeed $CapitalUniqueNumber } #for ($s = 1; $s -le $CapitalLetter; $s++) } #if ($CapitalLetter -ne 0) if ( $NumberTextBox -ne 0 -and $NumberTextBox .Text -match '[0-9]' -and $checkboxNumber .Checked -eq $true ) { for ( $N = 1 ; $N -le $NumberTextBox .Text ; $N ++) { $NumberUniqueNumber = Get-Rng $CompleteNumberPassword += Get-Random -InputObject $NumberTable -SetSeed $NumberUniqueNumber } #for ($s = 1; $s -le $Number; $s++) } #if ($Number -ne 0) if ( $SymbolTextBox -ne 0 -and $SymbolTextBox .Text -match '[0-9]' -and $checkboxSymbol .Checked -eq $true ) { for ( $sy = 1 ; $sy -le $SymbolTextBox .Text ; $sy ++) { $SymbolUniqueNumber = Get-Rng $CompleteSymbolPassword += Get-Random -InputObject $SymbolTable -SetSeed $SymbolUniqueNumber } #for ($sy = 1; $sy -le $Symbol; $sy++) } #if ($Symbol -ne 0) if ( $CapitalTextbox .Text -match '[0-9]' -and $SmallTextBox .Text -match '[0-9]' -and $NumberTextBox .Text -match '[0-9]' -and $SymbolTextBox .Text -match '[0-9]' ) { $ErrorMessage .Text = $null } else { $ErrorMessage .Text = "There is invalid character in one of the Textbox, type number" } $RandomOption += $CompleteSmallPassword $RandomOption += $CompleteCapitalPassword $RandomOption += $CompleteNumberPassword $RandomOption += $CompleteSymbolPassword #$CompletePassword = $RandomOption | Sort-Object {Get-Random (Get-Rng)} $CompletePassword = $RandomOption | Select-Object *, @ { N = 'Sort' ; E = { 1 .. 500 | Get-Random ( Get-Rng ) } } | Sort-Object -Property Sort $CompletePassword = $CompletePassword .Character -join '' } $Result .Text = $CompletePassword $Result .Text | clip $MessageResult .Text = 'Password copied on clipboard, use Ctrl+V to paste.' } $checkboxCapitalNumber_CheckedChanged ={ if ( $checkboxCapitalNumber .Checked -eq $true ) { $CapitalTextbox .Enabled = $true } else { $CapitalTextbox .Enabled = $false } if (( $checkboxCapitalNumber .Checked -eq $false ) -and ( $checkboxSmallNumber .Checked -eq $false ) -and ( $checkboxNumber .Checked -eq $false ) -and ( $checkboxSymbol .Checked -eq $false )) { $FirstRadioButton .Checked = $true $secondRadioButton .Checked = $false $PasswordLength .Enabled = $true #Disable make your own password $checkboxCapitalNumber .Enabled = $false $checkboxSmallNumber .Enabled = $false $checkboxNumber .Enabled = $false $checkboxSymbol .Enabled = $false $CapitalTextbox .Enabled = $false $SmallTextBox .Enabled = $false $SymbolTextBox .Enabled = $false $NumberTextBox .Enabled = $false } } $checkboxNumber_CheckedChanged ={ if ( $checkboxNumber .Checked -eq $true ) { $NumberTextbox .Enabled = $true } else { $NumberTextbox .Enabled = $false } if (( $checkboxCapitalNumber .Checked -eq $false ) -and ( $checkboxSmallNumber .Checked -eq $false ) -and ( $checkboxNumber .Checked -eq $false ) -and ( $checkboxSymbol .Checked -eq $false )) { $FirstRadioButton .Checked = $true $secondRadioButton .Checked = $false $PasswordLength .Enabled = $true #Disable make your own password $checkboxCapitalNumber .Enabled = $false $checkboxSmallNumber .Enabled = $false $checkboxNumber .Enabled = $false $checkboxSymbol .Enabled = $false $CapitalTextbox .Enabled = $false $SmallTextBox .Enabled = $false $SymbolTextBox .Enabled = $false $NumberTextBox .Enabled = $false } } $checkboxSmallNumber_CheckedChanged ={ if ( $checkboxSmallNumber .Checked -eq $true ) { $SmallTextbox .Enabled = $true } else { $SmallTextbox .Enabled = $false } if (( $checkboxCapitalNumber .Checked -eq $false ) -and ( $checkboxSmallNumber .Checked -eq $false ) -and ( $checkboxNumber .Checked -eq $false ) -and ( $checkboxSymbol .Checked -eq $false )) { $FirstRadioButton .Checked = $true $secondRadioButton .Checked = $false $PasswordLength .Enabled = $true #Disable make your own password $checkboxCapitalNumber .Enabled = $false $checkboxSmallNumber .Enabled = $false $checkboxNumber .Enabled = $false $checkboxSymbol .Enabled = $false $CapitalTextbox .Enabled = $false $SmallTextBox .Enabled = $false $SymbolTextBox .Enabled = $false $NumberTextBox .Enabled = $false } } $checkboxSymbol_CheckedChanged ={ if ( $checkboxSymbol .Checked -eq $true ) { $SymbolTextbox .Enabled = $true } else { $SymbolTextbox .Enabled = $false } if (( $checkboxCapitalNumber .Checked -eq $false ) -and ( $checkboxSmallNumber .Checked -eq $false ) -and ( $checkboxNumber .Checked -eq $false ) -and ( $checkboxSymbol .Checked -eq $false )) { $FirstRadioButton .Checked = $true $secondRadioButton .Checked = $false $PasswordLength .Enabled = $true #Disable make your own password $checkboxCapitalNumber .Enabled = $false $checkboxSmallNumber .Enabled = $false $checkboxNumber .Enabled = $false $checkboxSymbol .Enabled = $false $CapitalTextbox .Enabled = $false $SmallTextBox .Enabled = $false $SymbolTextBox .Enabled = $false $NumberTextBox .Enabled = $false } } $FirstRadioButton_CheckedChanged ={ $PasswordLength .Text = 12 $FirstRadioButton .Checked -eq $true #Disable second groupbox and textbox if ( $FirstRadioButton .Checked -eq $true ) { $FirstRadioButton .Checked = $true #Enable password length $PasswordLength .Enabled = $true #Disable make your own password $SecondRadioButton .Checked = $false $SecondRadioButton .Checked = $false $checkboxCapitalNumber .Enabled = $false $checkboxSmallNumber .Enabled = $false $checkboxNumber .Enabled = $false $checkboxSymbol .Enabled = $false $CapitalTextbox .Enabled = $false $SmallTextBox .Enabled = $false $SymbolTextBox .Enabled = $false $NumberTextBox .Enabled = $false } } $SecondRadioButton_CheckedChanged ={ #Disable first groupbox and textbox if ( $SecondRadioButton .Checked -eq $true ) { $FirstRadioButton .Checked = $false $PasswordLength .Enabled = $false #Enable make your own password #$SecondRadioButton.Checked = $true $checkboxCapitalNumber .Enabled = $true $checkboxSmallNumber .Enabled = $true $checkboxNumber .Enabled = $true $checkboxSymbol .Enabled = $true $CapitalTextbox .Enabled = $true $SmallTextBox .Enabled = $true $SymbolTextBox .Enabled = $true $NumberTextBox .Enabled = $true #Enable checkboxes $checkboxCapitalNumber .Checked = $true $checkboxSmallNumber .Checked = $true $checkboxNumber .Checked = $true $checkboxSymbol .Checked = $true #Set make your own default value $CapitalTextbox .Text = 4 $SmallTextbox .Text = 4 $SymbolTextbox .Text = 2 $NumberTextbox .Text = 2 } } $Form_StateCorrection_Load = { $formGenerateRandomPasswo .WindowState = $InitialFormWindowState } $Form_Cleanup_FormClosed = { try { $Result .remove_Click( $Result_Click ) $NumberTextBox .remove_TextChanged( $NumberTextBox_TextChanged ) $SymbolTextBox .remove_TextChanged( $SymbolTextBox_TextChanged ) $SmallTextBox .remove_TextChanged( $SmallTextBox_TextChanged ) $CapitalTextbox .remove_TextChanged( $CapitalTextbox_TextChanged ) $checkboxNumber .remove_CheckedChanged( $checkboxNumber_CheckedChanged ) $checkboxSymbol .remove_CheckedChanged( $checkboxSymbol_CheckedChanged ) $checkboxSmallNumber .remove_CheckedChanged( $checkboxSmallNumber_CheckedChanged ) $checkboxCapitalNumber .remove_CheckedChanged( $checkboxCapitalNumber_CheckedChanged ) $GeneratePassword12 .remove_Click( $GeneratePassword12_Click ) $SecondRadioButton .remove_CheckedChanged( $SecondRadioButton_CheckedChanged ) $groupbox1 .remove_Enter( $groupbox1_Enter ) $FirstRadioButton .remove_CheckedChanged( $FirstRadioButton_CheckedChanged ) $PasswordLength .remove_TextChanged( $PasswordLength_TextChanged ) $formGenerateRandomPasswo .remove_Load( $formGenerateRandomPasswo_Load ) $formGenerateRandomPasswo .remove_Load( $Form_StateCorrection_Load ) $formGenerateRandomPasswo .remove_FormClosed( $Form_Cleanup_FormClosed ) } catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } } $formGenerateRandomPasswo .SuspendLayout() $groupbox1 .SuspendLayout() $groupbox2 .SuspendLayout() $formGenerateRandomPasswo .Controls.Add( $ErrorMessage ) $formGenerateRandomPasswo .Controls.Add( $MessageResult ) $formGenerateRandomPasswo .Controls.Add( $linklabelHttpvcloudlabcom ) $formGenerateRandomPasswo .Controls.Add( $Result ) $formGenerateRandomPasswo .Controls.Add( $NumberTextBox ) $formGenerateRandomPasswo .Controls.Add( $SymbolTextBox ) $formGenerateRandomPasswo .Controls.Add( $SmallTextBox ) $formGenerateRandomPasswo .Controls.Add( $CapitalTextbox ) $formGenerateRandomPasswo .Controls.Add( $checkboxNumber ) $formGenerateRandomPasswo .Controls.Add( $checkboxSymbol ) $formGenerateRandomPasswo .Controls.Add( $checkboxSmallNumber ) $formGenerateRandomPasswo .Controls.Add( $checkboxCapitalNumber ) $formGenerateRandomPasswo .Controls.Add( $GeneratePassword12 ) $formGenerateRandomPasswo .Controls.Add( $groupbox1 ) $formGenerateRandomPasswo .Controls.Add( $groupbox2 ) $formGenerateRandomPasswo .AutoScaleDimensions = '6, 13' $formGenerateRandomPasswo .AutoScaleMode = 'Font' $formGenerateRandomPasswo .ClientSize = '424, 337' $formGenerateRandomPasswo .Name = 'formGenerateRandomPasswo' $formGenerateRandomPasswo .Text = 'Generate Random Password Tool' $formGenerateRandomPasswo .add_Load( $formGenerateRandomPasswo_Load ) $ErrorMessage .AutoSize = $True $ErrorMessage .Font = 'Microsoft Sans Serif, 10pt' $ErrorMessage .ForeColor = 'Red' $ErrorMessage .Location = '12, 226' $ErrorMessage .Name = 'ErrorMessage' $ErrorMessage .Size = '101, 17' $ErrorMessage .TabIndex = 15 $ErrorMessage .Text = 'Error Message' $MessageResult .AutoSize = $True $MessageResult .ForeColor = 'Red' $MessageResult .Location = '12, 298' $MessageResult .Name = 'MessageResult' $MessageResult .Size = '89, 13' $MessageResult .TabIndex = 14 $MessageResult .Text = 'Friendly Message' $linklabelHttpvcloudlabcom .Location = '297, 298' $linklabelHttpvcloudlabcom .Name = 'linklabelHttpvcloudlabcom' $linklabelHttpvcloudlabcom .Size = '115, 20' $linklabelHttpvcloudlabcom .TabIndex = 13 $linklabelHttpvcloudlabcom .TabStop = $True $linklabelHttpvcloudlabcom .Text = 'http://vcloud-lab.com' $Result .AutoSize = $True $Result .Font = 'Microsoft Sans Serif, 14pt' $Result .Location = '12, 259' $Result .Name = 'Result' $Result .Size = '230, 24' $Result .TabIndex = 10 $Result .Text = 'Password will display here' $Result .add_Click( $Result_Click ) $NumberTextBox .Location = '301, 186' $NumberTextBox .Name = 'NumberTextBox' $NumberTextBox .Size = '45, 20' $NumberTextBox .TabIndex = 9 $NumberTextBox .add_TextChanged( $NumberTextBox_TextChanged ) $SymbolTextBox .Location = '301, 156' $SymbolTextBox .Name = 'SymbolTextBox' $SymbolTextBox .Size = '45, 20' $SymbolTextBox .TabIndex = 8 $SymbolTextBox .add_TextChanged( $SymbolTextBox_TextChanged ) $SmallTextBox .Location = '301, 126' $SmallTextBox .Name = 'SmallTextBox' $SmallTextBox .Size = '45, 20' $SmallTextBox .TabIndex = 7 $SmallTextBox .add_TextChanged( $SmallTextBox_TextChanged ) $CapitalTextbox .Location = '301, 96' $CapitalTextbox .Name = 'CapitalTextbox' $CapitalTextbox .Size = '45, 20' $CapitalTextbox .TabIndex = 6 $CapitalTextbox .add_TextChanged( $CapitalTextbox_TextChanged ) $checkboxNumber .Location = '191, 184' $checkboxNumber .Name = 'checkboxNumber' $checkboxNumber .Size = '104, 22' $checkboxNumber .TabIndex = 4 $checkboxNumber .Text = 'Number' $checkboxNumber .UseVisualStyleBackColor = $True $checkboxNumber .add_CheckedChanged( $checkboxNumber_CheckedChanged ) $checkboxSymbol .Location = '191, 154' $checkboxSymbol .Name = 'checkboxSymbol' $checkboxSymbol .Size = '104, 22' $checkboxSymbol .TabIndex = 3 $checkboxSymbol .Text = 'Symbol' $checkboxSymbol .UseVisualStyleBackColor = $True $checkboxSymbol .add_CheckedChanged( $checkboxSymbol_CheckedChanged ) $checkboxSmallNumber .Location = '191, 124' $checkboxSmallNumber .Name = 'checkboxSmallNumber' $checkboxSmallNumber .Size = '104, 22' $checkboxSmallNumber .TabIndex = 2 $checkboxSmallNumber .Text = 'Small Number' $checkboxSmallNumber .UseVisualStyleBackColor = $True $checkboxSmallNumber .add_CheckedChanged( $checkboxSmallNumber_CheckedChanged ) $checkboxCapitalNumber .Location = '191, 94' $checkboxCapitalNumber .Name = 'checkboxCapitalNumber' $checkboxCapitalNumber .Size = '104, 22' $checkboxCapitalNumber .TabIndex = 1 $checkboxCapitalNumber .Text = 'Capital Number' $checkboxCapitalNumber .UseVisualStyleBackColor = $True $checkboxCapitalNumber .add_CheckedChanged( $checkboxCapitalNumber_CheckedChanged ) $GeneratePassword12 .Location = '12, 12' $GeneratePassword12 .Name = 'GeneratePassword12' $GeneratePassword12 .Size = '136, 23' $GeneratePassword12 .TabIndex = 0 $GeneratePassword12 .Text = 'New-GeneratePassword' $GeneratePassword12 .UseVisualStyleBackColor = $True $GeneratePassword12 .add_Click( $GeneratePassword12_Click ) $groupbox1 .Controls.Add( $SecondRadioButton ) $groupbox1 .Location = '177, 12' $groupbox1 .Name = 'groupbox1' $groupbox1 .Size = '207, 207' $groupbox1 .TabIndex = 11 $groupbox1 .TabStop = $False $groupbox1 .Text = 'Make your own password' $groupbox1 .add_Enter( $groupbox1_Enter ) $SecondRadioButton .Location = '14, 33' $SecondRadioButton .Name = 'SecondRadioButton' $SecondRadioButton .Size = '104, 24' $SecondRadioButton .TabIndex = 0 $SecondRadioButton .TabStop = $True $SecondRadioButton .Text = 'Select your own' $SecondRadioButton .UseVisualStyleBackColor = $True $SecondRadioButton .add_CheckedChanged( $SecondRadioButton_CheckedChanged ) $groupbox2 .Controls.Add( $labelPasswordLength ) $groupbox2 .Controls.Add( $FirstRadioButton ) $groupbox2 .Controls.Add( $PasswordLength ) $groupbox2 .Location = '12, 61' $groupbox2 .Name = 'groupbox2' $groupbox2 .Size = '146, 158' $groupbox2 .TabIndex = 12 $groupbox2 .TabStop = $False $groupbox2 .Text = 'Default 12 length' $labelPasswordLength .AutoSize = $True $labelPasswordLength .Location = '6, 65' $labelPasswordLength .Name = 'labelPasswordLength' $labelPasswordLength .Size = '89, 13' $labelPasswordLength .TabIndex = 7 $labelPasswordLength .Text = 'Password Length' $FirstRadioButton .Location = '6, 31' $FirstRadioButton .Name = 'FirstRadioButton' $FirstRadioButton .Size = '104, 24' $FirstRadioButton .TabIndex = 6 $FirstRadioButton .TabStop = $True $FirstRadioButton .Text = 'Random' $FirstRadioButton .UseVisualStyleBackColor = $True $FirstRadioButton .add_CheckedChanged( $FirstRadioButton_CheckedChanged ) $PasswordLength .Location = '100, 61' $PasswordLength .Name = 'PasswordLength' $PasswordLength .Size = '40, 20' $PasswordLength .TabIndex = 5 $PasswordLength .add_TextChanged( $PasswordLength_TextChanged ) $groupbox2 .ResumeLayout() $groupbox1 .ResumeLayout() $formGenerateRandomPasswo .ResumeLayout() $InitialFormWindowState = $formGenerateRandomPasswo .WindowState #Init the OnLoad event to correct the initial state of the form $formGenerateRandomPasswo .add_Load( $Form_StateCorrection_Load ) #Clean up the control events $formGenerateRandomPasswo .add_FormClosed( $Form_Cleanup_FormClosed ) #Show the Form return $formGenerateRandomPasswo .ShowDialog() } #End Function #Call the form New-RandomPasswordGUI | Out-Null