Security Focus: Generate an Alphanumeric Password
If you have to have a password, it's best to have a password that could contain special characters... but, what if you want to generate a password without special characters?
Here's a little function to do just that:
function New-AlphaNumericPassword {
##14 characters
##no special characters
##ASCII
#48 -> 57 :: 0 -> 9
#65 -> 90 :: A -> Z
#97 -> 122 :: a -> z
$c = $null
for ($i = 1; $i -lt 15; $i++) {
$a = Get-Random -Minimum 1 -Maximum 4
switch ($a) {
1 {$b = Get-Random -Minimum 48 -Maximum 58}
2 {$b = Get-Random -Minimum 65 -Maximum 91}
3 {$b = Get-Random -Minimum 97 -Maximum 123}
}
[string]$c += [char]$b
}
$c
}
At Microsoft, we don't use passwords anymore. We use Windows Hello for Business on PCs and mobile devices - it replaces passwords with strong two-factor authentication, which is tied to the device and utilises a biometric or PIN.
In my personal life, I enable two-factor authentication on everything I can. It's initially inconvenient, but, once you get used to it, the security it affords is reassuring. You can make you life much easier with apps like the Microsoft Authenticator.