/PSRandomPassword

Powershell Implementation of RandomPassword

Primary LanguagePowerShell

Random Password Power Shell Module

A powershell module for generating random passwords

Install Module

Install-Module PSRandomPassword

Use Module

Get-RandomPassword [[-Count] ] [[-Type] ] [[-Length] ] [[-Digits] ] [[-Seed] ] [[-JsonFile] ] [-Lower] [-Upper] [-GenerateJson]

It looks for "randompassword.json" in the same folder and if it exists it'll load the strings in that file instead of using
the hardcoded strings.

basic json file structure:
{
    "digits" : 3,
    "first" : [
        "firstwords",
        "..."
    ],
    "second" : [
        "secondwords",
        "..."
    ],
    "symbols" : [
        "!",
        "?",
        "%",
        "#"
    ]
    "passwordtypes" : [
        {"standard" : "[Word1][Word2][0-9]{3}[symbol]"},
        {"o365" : "[CONSONANT][vowel][consonant][0-9]{5}"},
        {"gibberish" : "[random]{length}"}
    ]
}

Usage: Get-RandomPassword [-Count count] [-Seed seed] [-JsonFile jsonfile] [[-Type type] [-Length length] | [[-Lower] | [-Upper]] [-Digits count] | [-GenerateJson]]

Options:
    -Count count      Number of passwords to generate.
    -Type type        Types: standard, o365, gibberish, custom.
                      O365 password (3 letters 5 numbers).
                      Gibberish password (Random characters).
                      Custom password (similar to regex use Get-Help Get-RandomPassword -full for further help).
                      (Custom types can be added/removed/edited in a JSON file by generating a JSON file using
                      -GenerateJson).
    -Length length    Length of gibberish password and the Length variable used in {length}.
    -Lower            Passwords to be all lowercase.
    -Upper            Passwords to be all uppercase.
    -Digits count     Digit count in password. (100 limit).
    -Seed seed        RNG Seed. Uses time by default.
    -JsonFile file    Specify a JSON file to use instead of the default "randompassword.json".
    -GenerateJson     Generates a default JSON file.

Custom password:
    Custom password allows you to specify a random password based on specified expression.
    Similar to regular expressions.

    Usage: Get-RandomPassword -Type custom "EXPR"
        [x-x]        Range of characters e.g. [0-9],[a-z],[a-Z].
        [x]          Type of characters e.g. [vowel],[consonant],[symbol].
                     [VOWEL] and [CONSONANT] will produce an uppercase character.
        [word1]      Random word from first array. word1 will produce an lowercase word
                     WORD1 an uppercase word and Word1 a propercase word.
        [word2]      Random word from first array. word2 will produce an lowercase word
                     WORD2 an uppercase word and Word2 a propercase word.
        [random]     A random character.
        x            literial character e.g. abc
        {x}          Character count of range e.g. {3}.
        {digits}     Character count set to digits value in JSON or if specified with -Digits.
        {length}     Character count set to length specified with -Length.

    Example: Get-RandomPassword -Type custom:"[symbol][a-z]{4}[A-Z]{3}[0-9]{2}-[a-Z]{4}[symbol][symbol]"
             Could generate a password of: !efyrEKS48-GHsR?!

Example:
Return 1 password:
    Get-RandomPassword

Return 100 passwords:
    Get-RandomPassword -Count 100
    
Return 10 passwords in lowercase:
    Get-RandomPassword -Count 10 -Lower
    
Return 10 passwords with no digits:
    Get-RandomPassword -Count 10 -Digits 0
    
Return office 365 password format:
    Get-RandomPassword -Type o365
    
Return gibberish password 16 in length:
    Get-RandomPassword -Type gibberish -Length 16