40 lines
808 B
PowerShell
40 lines
808 B
PowerShell
$RootDirectory = "F:\Documents\IDB\Internal IT\Asset Provisioning\User Accounts\PasswordGenerator"
|
|
|
|
|
|
function Get-RandomWord
|
|
{
|
|
if(-not $words)
|
|
{
|
|
|
|
$WordsFile = $RootDirectory + "\words.json"
|
|
$Script:words = Get-Content -Raw -Path $WordsFile | convertfrom-json
|
|
|
|
}
|
|
|
|
$words["$(get-random -Maximum ($words.count))"]
|
|
}
|
|
|
|
function Get-RandomCharacter
|
|
{
|
|
if(-not $character)
|
|
{
|
|
|
|
$character = "!£$%^&)(-_{}[];#.\|<:@~+"
|
|
|
|
}
|
|
|
|
$character["$(get-random -Maximum ($character.Length))"]
|
|
}
|
|
|
|
$UpperCaseWord = Get-RandomWord as string
|
|
|
|
|
|
$LowerCaseWord = Get-RandomWord
|
|
|
|
$Number = Get-Random -Minimum 10 -Maximum 99
|
|
|
|
$RandomCharacter = Get-RandomCharacter
|
|
|
|
$Password = $LowerCaseWord + $RandomCharacter + $UpperCaseWord.ToUpper() + $RandomCharacter + $Number
|
|
|
|
$Password | Set-Clipboard |