help New-Password -Full
NAME
New-Password
SYNOPSIS
Function to generate random password
SYNTAX
New-Password [[-Length] <Int32>] [[-Include] <String[]>] [-CodeFriendly] [<CommonParameters>]
DESCRIPTION
Function to generate random password
PARAMETERS
-Length <Int32>
Number between 2 and 256
Default is 24
Required? false
Position? 1
Default value 24
Accept pipeline input? false
Accept wildcard characters? false
-Include <String[]>
One or more of the following:
UpperCase
LowerCase
Numbers
SpecialCharacters
Default is all 4
Required? false
Position? 2
Default value @('UpperCase','LowerCase','Numbers','SpecialCharacters')
Accept pipeline input? false
Accept wildcard characters? false
-CodeFriendly [<SwitchParameter>]
When set to True, this function excludes the following 4 characters from the 'SpecialCharacters' list of the password
" ==> ASCII 34
$ ==> ASCII 36
' ==> ASCII 39
` ==> ASCII 96
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Function by Sam Boutros
v0.1 - 27 July 2017
v0.2 - 3 May 2020 - included in AZSBTools PS module
v0.3 - 19 October 2020 - Added Switch to remove 4 code unfriendly characters
-------------------------- EXAMPLE 1 --------------------------
PS C:\>New-Password
-------------------------- EXAMPLE 2 --------------------------
PS C:\>New-Password -Length 10 -Include LowerCase,UpperCase,Numbers -Verbose
RELATED LINKS
https://superwidgets.wordpress.com/category/powershell/
If you don’t know all the ASCII code ranges and don’t have PowerShell v6+, you can opt for an all inclusive ASCII range and use regex matching to filter it down. Then pipe to Get-Random for your length: