个人开发代码分享

随机生成密码

# Function to generate a random string with excluded characters
function Generate-RandomString {
# Define character sets excluding 'o', '0', 'i', 'l', '1'
$upperChars = "A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"
$lowerChars = "a","b","c","d","e","f","g","h","j","k","m","n","p","q","r","s","t","u","v","w","x","y","z"
$numbers = "2","3","4","5","6","7","8","9"

# Generate the first random uppercase letter
$firstChar = $upperChars | Get-Random

# Generate two random lowercase letters
$nextChars = -join ($lowerChars | Get-Random -Count 2)

# Generate five random digits
$randomNumbers = -join ($numbers | Get-Random -Count 5)

# Combine the characters and numbers
$result = $firstChar + $nextChars + $randomNumbers

# Output the result
return $result
}
# Repeat the process 10 times
for ($i = 0; $i -lt 10; $i++) {
Write-Output (Generate-RandomString)
}

琼ICP备2025062624号