QuickPasswordGenerator.psm1

#
#
# Quick Password Generator
#
#


$ErrorActionPreference = 'Stop'


#
# Module functions
#


Function Invoke-QuickPasswordGenerator {

    <#
 
     .SYNOPSIS
     Generate random passwords
 
     .DESCRIPTION
     Generate random fixed length passwords
 
     .PARAMETER PasswordLength
     The password's number of characters
 
     .PARAMETER PasswordCount
     The number of passwords to generate
 
     .EXAMPLE
     Invoke-QuickPasswordGenerator -PasswordLength 20 -PasswordCount 10
 
     .NOTES
     + Password:
       - Minimum lenght = 10
       - Maximum length = 66
       - Default length = 16
 
     .LINK
     None
 
    #>


    Param (

        [Int]$PasswordLength,
        [Int]$PasswordCount

    )

    BEGIN {

        If ($PasswordLength -lt 10) {

            $PasswordLength = 16

        }

    }

    PROCESS {

        For ($Index; $Index -lt $PasswordCount; $Index++) {

            $Characters = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz123456789!@#$%^&*-'
            $Password = -Join ($Characters.ToCharArray() | Get-Random -Count $PasswordLength)

            [PSCustomObject]@{

                'Count' = $Index + 1
                'Password' = $Password
                'Length' = $Password.Length

            }

        }

    }

    END {}

}