function New-SecurePassword { <# .SYNOPSIS Generates a secure password. .DESCRIPTION Generates a secure password containing at least one uppercase, one lowercase, one number and one special character. .PARAMETER PasswordLength [byte] Length of the desired password. .PARAMETER ProfileName [string] The AWS profile to use during password generation. .PARAMETER Region [string] The AWS region to use during password generation. .PARAMETER ExcludeCharacters [string] String containing characters to exclude from the generated password. .EXAMPLE New-SecurePassword -PasswordLength 10 -ProfileName 'temp-dev' -Region 'us-east-1' u48d![N[s^ #> [CmdletBinding()] [OutputType([string])] param( [Parameter(Mandatory = $false)] [ValidateRange(4, 128)] [byte]$PasswordLength = 15, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $ProfileName, [Parameter(Mandatory = $true)] [ValidateScript({$_ -in (Get-AWSRegion).region})] [string] $Region, [Parameter(Mandatory = $false)] [string]$ExcludeCharacter = "`"';@`$``%<>=/\" ) # This function is just a convenience wrapper to allow us to default the exclusion list to remove "problematic" # characters from generated passwords. Import-AWSModule return ( Get-SECRandomPassword -ProfileName $ProfileName -Region $Region -RequireEachIncludedType $true -PasswordLength $PasswordLength -ExcludeCharacter $ExcludeCharacter ) }