Skip to main content

New-RandomPassword

SYNOPSIS​

Create pseudo random password

SYNTAX​

FixedLength (Default)​

New-RandomPassword
[-PasswordLength <Int32>]
[-InputStrings <String[]>]
[-FirstChar <String>]
[-Count <Int32>]
[<CommonParameters>]

RandomLength​

New-RandomPassword
[-MinPasswordLength <Int32>]
[-MaxPasswordLength <Int32>]
[-InputStrings <String[]>]
[-FirstChar <String>]
[-Count <Int32>]
[<CommonParameters>]

DESCRIPTION​

Create a random password which can be used for one-time passwords if the the password reset functionality in Cumulocity is not available.

EXAMPLES​

EXAMPLE 1​

New-RandomPassword

C&3SX6Kn

Generate one password with a length between 8 and 12 chars.

EXAMPLE 2​

New-RandomPassword -MinPasswordLength 8 -MaxPasswordLength 12 -Count 4

7d&5cnaB !Bh776T"Fw 9"C"RxKcY %mtM7#9LQ9h

Generate four passwords, each with a length of between 8 and 12 chars.

EXAMPLE 3​

New-RandomPassword -InputStrings abc, ABC, 123 -PasswordLength 4

3ABa

Generate a password with a length of 4 containing at least one char from each InputString

EXAMPLE 4​

New-RandomPassword -InputStrings abc, ABC, 123 -PasswordLength 4 -FirstChar abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
3ABa

Generates a password with a length of 4 containing at least one char from each InputString that will start with a letter from the string specified with the parameter FirstChar

PARAMETERS​

-MinPasswordLength​

Specifies minimum password length

Type: Int32
Parameter Sets: RandomLength
Aliases: Min

Required: False
Position: Named
Default value: 12
Accept pipeline input: False
Accept wildcard characters: False

-MaxPasswordLength​

Specifies maximum password length

Type: Int32
Parameter Sets: RandomLength
Aliases: Max

Required: False
Position: Named
Default value: 20
Accept pipeline input: False
Accept wildcard characters: False

-PasswordLength​

Specifies a fixed password length

Type: Int32
Parameter Sets: FixedLength
Aliases:

Required: False
Position: Named
Default value: 12
Accept pipeline input: False
Accept wildcard characters: False

-InputStrings​

Specifies an array of strings containing character groups from which the password will be generated. At least one char from each group (string) will be used.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: @('abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '123456789', '!#%()[]*+-_;,.')
Accept pipeline input: False
Accept wildcard characters: False

-FirstChar​

Specifies a string containing a character group from which the first character in the password will be generated. Useful for systems which requires first char in password to be alphabetic.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Count​

Specifies number of passwords to generate.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters​

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS​

OUTPUTS​

[String]​

NOTES​

http://blog.simonw.se/powershell-generating-random-password-for-active-directory/