Advanced Password Generator Tool
<# .SYNOPSIS Advanced Password Generator Tool .DESCRIPTION This script provides an advanced password generation tool with features including customizable generation criteria, password strength evaluation, password history, and additional utility functions. .NOTES File Name : AdvancedPasswordGenerator.ps1 Author : [Your Name] Prerequisite : PowerShell V5.1 or later Version : 1.0 Date : [Current Date] .EXAMPLE .\AdvancedPasswordGenerator.ps1 #> # Import required modules Add-Type -AssemblyName System.Web # Global variables $script:passwordHistory = @() $script:maxHistorySize = 10 $script:passwordFilePath = Join-Path -Path $env:USERPROFILE -ChildPath "Documents\PasswordGeneratorHistory.txt" function Show-Menu { Clear-Host Write-Host "=== Advanced Password Generator Tool ===" -ForegroundColor Cyan Write-Host "1. Generate Password" Write-Host "2. Set Password Options" Write-Host "3. View Current Settings" Write-Host "4. View Password History" Write-Host "5. Evaluate Password Strength" Write-Host "6. Generate Passphrase" Write-Host "7. Export Password History" Write-Host "8. Exit" } function Set-PasswordOptions { $script:passwordLength = Read-Host "Enter password length (default is 16)" if ([string]::IsNullOrWhiteSpace($script:passwordLength)) { $script:passwordLength = 16 } $script:includeUppercase = Read-Host "Include uppercase letters? (Y/N, default is Y)" $script:includeUppercase = ($script:includeUppercase -ne 'N') $script:includeLowercase = Read-Host "Include lowercase letters? (Y/N, default is Y)" $script:includeLowercase = ($script:includeLowercase -ne 'N') $script:includeNumbers = Read-Host "Include numbers? (Y/N, default is Y)" $script:includeNumbers = ($script:includeNumbers -ne 'N') $script:includeSpecialChars = Read-Host "Include special characters? (Y/N, default is Y)" $script:includeSpecialChars = ($script:includeSpecialChars -ne 'N') $script:excludeSimilarChars = Read-Host "Exclude similar characters (O, 0, I, l, 1)? (Y/N, default is N)" $script:excludeSimilarChars = ($script:excludeSimilarChars -eq 'Y') Write-Host "Password options updated." -ForegroundColor Green } function View-CurrentSettings { Write-Host "`nCurrent Password Generation Settings:" -ForegroundColor Yellow Write-Host "Password Length: $script:passwordLength" Write-Host "Include Uppercase: $($script:includeUppercase ? 'Yes' : 'No')" Write-Host "Include Lowercase: $($script:includeLowercase ? 'Yes' : 'No')" Write-Host "Include Numbers: $($script:includeNumbers ? 'Yes' : 'No')" Write-Host "Include Special Characters: $($script:includeSpecialChars ? 'Yes' : 'No')" Write-Host "Exclude Similar Characters: $($script:excludeSimilarChars ? 'Yes' : 'No')" Write-Host "" } function Generate-Password { $characterSet = @() if ($script:includeUppercase) { $characterSet += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.ToCharArray() } if ($script:includeLowercase) { $characterSet += 'abcdefghijklmnopqrstuvwxyz'.ToCharArray() } if ($script:includeNumbers) { $characterSet += '0123456789'.ToCharArray() } if ($script:includeSpecialChars) { $characterSet += '!@#$%^&*()_+-=[]{}|;:,.<>?'.ToCharArray() } if ($script:excludeSimilarChars) { $characterSet = $characterSet | Where-Object { $_ -notin 'O', '0', 'I', 'l', '1' } } if ($characterSet.Count -eq 0) { Write-Host "Error: No character set selected. Please update your settings." -ForegroundColor Red return } $password = -join (1..$script:passwordLength | ForEach-Object { Get-Random -InputObject $characterSet }) Write-Host "`nGenerated Password:" -ForegroundColor Green Write-Host $password Write-Host "" $strength = Evaluate-PasswordStrength -Password $password Write-Host "Password Strength: $strength" -ForegroundColor Yellow Add-ToPasswordHistory -Password $password $saveToFile = Read-Host "Do you want to save this password to a file? (Y/N)" if ($saveToFile -eq 'Y') { $fileName = "GeneratedPassword_$(Get-Date -Format 'yyyyMMdd_HHmmss').txt" $filePath = Join-Path -Path $env:USERPROFILE -ChildPath "Desktop\$fileName" $password | Out-File -FilePath $filePath Write-Host "Password saved to: $filePath" -ForegroundColor Green } } function Evaluate-PasswordStrength { param ([string]$Password) $score = 0 if ($Password.Length -ge 12) { $score += 2 } elseif ($Password.Length -ge 8) { $score += 1 } if ($Password -cmatch "[A-Z]") { $score += 1 } if ($Password -cmatch "[a-z]") { $score += 1 } if ($Password -match "\d") { $score += 1 } if ($Password -match "[^a-zA-Z0-9]") { $score += 1 } switch ($score) { 0 { return "Very Weak" } 1 { return "Weak" } 2 { return "Moderate" } 3 { return "Strong" } 4 { return "Very Strong" } default { return "Extremely Strong" } } } function Add-ToPasswordHistory { param ([string]$Password) $script:passwordHistory = @($Password) + $script:passwordHistory if ($script:passwordHistory.Count -gt $script:maxHistorySize) { $script:passwordHistory = $script:passwordHistory[0..($script:maxHistorySize - 1)] } } function View-PasswordHistory { if ($script:passwordHistory.Count -eq 0) { Write-Host "Password history is empty." -ForegroundColor Yellow return } Write-Host "`nPassword History (Most Recent First):" -ForegroundColor Yellow for ($i = 0; $i -lt $script:passwordHistory.Count; $i++) { Write-Host "$($i + 1). $($script:passwordHistory[$i])" } Write-Host "" } function Generate-Passphrase { $wordList = @("apple", "banana", "cherry", "date", "elderberry", "fig", "grape", "honeydew", "kiwi", "lemon", "mango", "nectarine", "orange", "papaya", "quince", "raspberry", "strawberry", "tangerine", "ugli", "vanilla", "watermelon", "xigua", "yuzu", "zucchini") $passphrase = -join ((1..4 | ForEach-Object { Get-Random -InputObject $wordList }) -join "-") Write-Host "`nGenerated Passphrase:" -ForegroundColor Green Write-Host $passphrase Write-Host "" Add-ToPasswordHistory -Password $passphrase } function Export-PasswordHistory { if ($script:passwordHistory.Count -eq 0) { Write-Host "Password history is empty. Nothing to export." -ForegroundColor Yellow return } $script:passwordHistory | Out-File -FilePath $script:passwordFilePath Write-Host "Password history exported to: $script:passwordFilePath" -ForegroundColor Green } # Initialize default settings $script:passwordLength = 16 $script:includeUppercase = $true $script:includeLowercase = $true $script:includeNumbers = $true $script:includeSpecialChars = $true $script:excludeSimilarChars = $false # Main program loop do { Show-Menu $choice = Read-Host "`nEnter your choice (1-8)" switch ($choice) { "1" { Generate-Password } "2" { Set-PasswordOptions } "3" { View-CurrentSettings } "4" { View-PasswordHistory } "5" { $pwToEvaluate = Read-Host "Enter a password to evaluate" $strength = Evaluate-PasswordStrength -Password $pwToEvaluate Write-Host "Password Strength: $strength" -ForegroundColor Yellow } "6" { Generate-Passphrase } "7" { Export-PasswordHistory } "8" { Write-Host "Exiting program..." -ForegroundColor Yellow; break } default { Write-Host "Invalid choice. Please try again." -ForegroundColor Red } } if ($choice -ne "8") { Read-Host "`nPress Enter to continue..." } } while ($choice -ne "8")
This Advanced Password Generator Tool includes:
- A menu-driven interface with expanded options.
- Enhanced functions for password generation and management:
- Customizable password generation with more options
- Password strength evaluation
- Password history tracking
- Passphrase generation
- Export functionality for password history
- Additional features:
- Option to exclude similar characters (O, 0, I, l, 1) for improved readability
- Passphrase generation using a predefined word list
- Ability to evaluate the strength of any given password
- Password history with a configurable size limit
- Export functionality to save password history to a file
Key features:
- More flexible and customizable password generation
- Built-in password strength evaluation
- Password history tracking for easy reference
- Passphrase generation as an alternative to traditional passwords
- Ability to export password history for backup or review
- Enhanced user interface with more options and information
This tool is particularly useful for:
- System administrators requiring advanced password management capabilities
- Security professionals needing to generate and evaluate various types of passwords
- Users who want a comprehensive tool for creating and managing strong passwords
- IT professionals implementing or reviewing password policies
To use this script effectively:
- Run the script in PowerShell
- Use the expanded menu to access various features
- Customize password generation settings as needed
- Generate passwords or passphrases
- Use the password strength evaluation feature to check existing passwords
- Manage and export password history as required
This advanced script provides a more comprehensive approach to password generation and management, offering additional features for security-conscious users and professionals.