Skip to content

Instantly share code, notes, and snippets.

@jrotello
Last active November 7, 2019 17:30
Show Gist options
  • Save jrotello/d88f87baecf2560c7e1896e939ccc198 to your computer and use it in GitHub Desktop.
Save jrotello/d88f87baecf2560c7e1896e939ccc198 to your computer and use it in GitHub Desktop.
Simple random password generator
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