Get-PasswordNumber
Description
Get-PasswordNumber will calculate the number of possible passwords that you are able to generate based on your input and parameters. You can use this command to know beforehand what is the expected output when you want to create a dictionary file. It will provide you the number of combinations before you go and create them on screen or in a dictionary file.
Note: You need to install DictionaryFile module version 2.0 in order for this cmdlet to be available. For more information, see PowerShell Module DictionaryFile v2.0.
Syntax:
Get-PasswordNumber [-CharacterSet] <String> [-MinCharacters] <UInt32> [-MaxCharacters] <UInt32> [-IncludeCapital] [-CapitalOnly] [<CommonParameters>]
If you want to find more about the specific cmdlet while you are in PowerShell you can use the below to get the help file.
Code:
Get-Help Get-PasswordNumber
Output:
Now lets see few examples about Get-PasswordNumber
.
[adinserter name=”In Article”]
Examples
Example 1
In this example we will get the number of possible passwords that are two to five characters based on the character set “a,b,c,1,2,3,$,*,&”.
PS C:\> Get-PasswordNumber -CharacterSet "a,b,c,1,2,3,$,*,&" -MinCharacters 2 -MaxCharacters 5 66420
Example 2
We will use the same characters as example 1 but we would like also to include the capital letters of “a,b,c”.
PS C:\> Get-PasswordNumber -Characters "a,b,c,1,2,3,$,*,&" -MinCharacters 2 -MaxCharacters 5 -IncludeCapital 271440
Example 3
For this example we need only the capital letters of “a,b,c” using the same character set of example 1.
PS C:\> Get-PasswordNumber -Characters "a,b,c,1,2,3,$,*,&" -MinCharacters 2 -MaxCharacters 5 -CapitalOnly 66420
Example 4
If we want to use the whole alphabet without any numbers and symbols, then we can use the word alphabet for our characters set.
PS C:\> Get-PasswordNumber -Characters alphabet -MinCharacters 2 -MaxCharacters 5 12356604
Example 5
We are able also to keep a specific pattern in our generated passwords, by defining more than one characters between commas.
Get-PasswordNumber "av,b,c" -MinCharacters 2 -MaxCharacters 2 9
Example 6
Get-Password can accept String values from the pipeline.
PS C:\> "a,b,c" | Get-PasswordNumber -MinCharacters 2 -MaxCharacters 2 9
Example 7
You can also use the output of the cmdlet into other commands.
PS C:\> Get-PasswordNumber -CharacterSet "ad,b,c" -MinCharacters 2 -MaxCharacters 2 | ForEach-Object {$_ * 2} 18
[adinserter name=”In Article”]
Required Parameters
-CharacterSet
- Description: Specifies the characters (letters, numbers, symbols) that need to be included.
- Required: True
- Position: 1
- Default value: None
- Accept pipeline input: True (ByValue)
- Accept wildcard characters: False
-MinCharacters
- Description: Specifies the minimum characters of the generated passwords.
- Required: True
- Position: 2
- Default value: 0
- Accept pipeline input: False
- Accept wildcard characters: False
-MaxCharacters
- Descriptions: Specifies the maximum characters of the generated passwords.
- Required: True
- Position: 3
- Default value: 0
- Accept pipeline input: False
- Accept wildcard characters: False
Optional Parameters
-IncludeCapital
- Description: Specifies whether or not to include upper case letters along with the lower case letters.
- Required: False
- Position: named
- Default value: False
- Accept pipeline input: False
- Accept wildcard characters: False
-CapitalOnly
- Description: Specifies whether or not all lower case letters to be converted to upper case letters.
- Required: False
- Position: named
- Default value: False
- Accept pipeline input: False
- Accept wildcard characters: False
Inputs
System.String.
Get-PasswordNumber can accept a string value to determine the CharacterSet parameter.
Outputs
System.Double.
Get-PasswordNumber returns the number of passwords that can be created.
[adinserter name=”In Article”]
Related Links
- PowerShell Module DictionaryFile v 2.0
- Get-PasswordCombination
- New-DictionaryFile
- Get-DictionaryFile
- PowerShell Gallery | DictionaryFile 2.0
- GitHub – SConstantinou/DictionaryFile
[adinserter name=”Matched-Content”]


Leave a Reply