Whenever you need to create a new random password, be sure to check out this function:
function Get-RandomPassword {
param(
$length = 10,
$characters =
param(
$length = 10,
$characters =
'abcdefghkmnprstuvwxyzABCDEFGHKLMNPRSTUVWXYZ123456789!"§$%&/()=?*+#_'
)
# select random characters
$random = 1..$length | ForEach-Object { Get-Random -Maximum $characters.length }
# output random pwd
$private:ofs=""
[String]$characters[$random]
}
)
# select random characters
$random = 1..$length | ForEach-Object { Get-Random -Maximum $characters.length }
# output random pwd
$private:ofs=""
[String]$characters[$random]
}
You can specify the length and submit a pool of characters that your password could contain. By default, the function will use characters, numbers, and special characters and will avoid characters like "o" and "0" that could be misinterpreted.