Last active
November 7, 2019 17:30
-
-
Save jrotello/d88f87baecf2560c7e1896e939ccc198 to your computer and use it in GitHub Desktop.
Simple random password generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-RandomPassword { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory = $true)] | |
[ValidateRange(8, 64)] | |
[int]$Length | |
) | |
$alphabet = | |
[char[]]'!@#$%^&*+?' + | |
[char[]]'0123456789' + | |
[char[]]'abcdefghijklmnopqrstuvwxyz' + | |
[char[]]'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
-join (Get-Random -InputObject $alphabet -Count $Length | % { [char]$_ }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment