Skip to content

Generate a random string for passwords

This article explains how to generate random strings, which is useful for things like creating passwords.

Copy the following code and paste it into the Power Automate Desktop flow designer to add the action.

Text.Random UseUpperCaseLetters: True UseLowerCaseLetters: True UseDigits: True UseSymbols: True MinimumLength: 6 MaximumLength: 10 RandomText=> RandomText
  1. In “Search actions”, type “Create random text” and set the parameters as follows.

    Parameter Value
    Use uppercase letters (A-Z) Turn on to allow uppercase letters
    Use lowercase letters (a-z) Turn on to allow lowercase letters
    Use digits (0-9) Turn on to allow digits
    Use symbols Turn on to allow symbols
    Minimum length The minimum number of characters to generate
    Maximum length The maximum number of characters to generate
  2. Save and run the flow to generate a random string that changes on every run. If you specify the same value for the minimum and maximum length, you can fix the number of characters.

If you need rules for specific character positions, you need to create several random strings and then join them.

As an example, this section generates a string whose first 2 characters are always digits and whose remaining 6 characters are letters.

Copy the following code and paste it into the Power Automate Desktop flow designer to add the action.

Text.Random UseUpperCaseLetters: False UseLowerCaseLetters: False UseDigits: True UseSymbols: False MinimumLength: 2 MaximumLength: 2 RandomText=> RandomText1
Text.Random UseUpperCaseLetters: True UseLowerCaseLetters: True UseDigits: False UseSymbols: False MinimumLength: 6 MaximumLength: 6 RandomText=> RandomText2
Text.JoinText.Join List: [RandomText1, RandomText2] Result=> JoinedText
  1. Using the method described above, generate two random strings (RandomText1 and RandomText2) with “Create random text”.

  2. In “Search actions”, search for “Join text” and set the parameters as follows.

    Parameter Value
    Specify the list to join %[RandomText1, RandomText2]%
    Delimiter to separate list items None
  3. When you run the flow, a random string that follows the rules is generated.