How to generate random password

Hi Experts,
i using some cmdlets to generate random password.
$ascii=$NULL;
For ($a=97;($a –le 122);$a++) {$ascii+=,[char][byte]$a }
$No_of_password  = 6
$length_of_password = 10
$TempPassword=$NULL     # To store single password
$Morepassword=@()  # Variable to 'X' no. of passwords
 for ($lp=0; $lp -le $count; $lp++ )
For ($loop=1; $loop –le $length; $loop++)
    $TempPassword+=($ascii | GET-RANDOM)   # this generate the random password
$morepassword[$lp]= $TempPassword 
$morepassword    # This should give the all random password
Output is like --- 
=zM;HFuElY
=zM;HFuElYp88<kqTOVM
=zM;HFuElYp88<kqTOVMfS1xR01VzY
=zM;HFuElYp88<kqTOVMfS1xR01VzY4<$wG%Z>ft
=zM;HFuElYp88<kqTOVMfS1xR01VzY4<$wG%Z>ft=a&ME7>&3T
=zM;HFuElYp88<kqTOVMfS1xR01VzY4<$wG%Z>ft=a&ME7>&3T$98v$b>jSU
This is not required output. It should give the output like
=zM;HFuElY
p88<kqTOVM
fS1xR01VzY
4<$wG%Z>ft
=a&ME7>&3T
$98v$b>jSU
Total 6 passwords with a length of 10
How do create a array like this ?

I agree with Fred but here i shwo to manage two loops with PowerShell.
$pwdchars=33..122|%{[char]$_}
1..6|
ForEach-Object{
$pwd=''
1..10 |
ForEach-Object{
$pwd+=$pwdchars | GET-RANDOM
$pwd
It is usually always better to write less code and to use the code correctly.  YOu have guessed at mmost of the code but have not used consistent variables.  My guess is that you have tried to modify somecode you found.  Look at this code
to see how easy it is to build loops in PowerShell
¯\_(ツ)_/¯

Similar Messages

  • How to generate random password as per password policy by knowing the resou

    Hi,
    Any body tell me, how to generate random password as per password policy by knowing the resource object in OIM11g
    Regards,
    Nishith Nayan

    Hi Nayan,
    You can try below code snippet:
    UserRepository ur = new DBUserRepository();
    UserInfo user = ur.getUserInfo(userKey);     
                   ResourceRepository rrepo = new ResourceDBRepository();
                   Resource resource = rrepo.findResource(resourceName);
                   PasswordPolicyAssignmentsRepository par = new PasswordPolicyAssignmentsDBRepository();
                   PasswordPolicyRepository ppr = new DBPasswordPolicyRepository();               
                   List passwordPolicyAssignments = par.getPasswordPolicyAssigments(resource);     
                   PasswordPolicy passwordPolicy;     
                                            PasswordPolicyAssignment passwordPolicyAssignment = (PasswordPolicyAssignment) passwordPolicyAssignments.get(0);
                             if (isApplicable(passwordPolicyAssignment, getMappedAttributes(userInfo.getAttributes()))) {                            
                                  passwordPolicy = ppr.find(passwordPolicyAssignment.getPasswordPolicyID());                    
                                                 RandomPasswordGeneratorImpl rpg = new RandomPasswordGeneratorImpl();
                             password = rpg.generatePassword(userInfo, passwordPolicy);
    regards,
    gyan

  • How to create a javabean that generate random password?

    May i know how to create a javabean that can generate random password?
    that include character and string
    and length of 10.

    i created a class file for my java bean
    package autogenerate;
    import java.util.*;
    public class GeneratePwId
    private int MemId;
    private String Passwd;
    public GeneratePwId(){}
    public String getPasswd()
    return this.Passwd;
    public void setPasswd()
    char[] letters = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
    'J', 'K', 'L', 'M', 'N', 'P', 'R', 'T',
    'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c',
    'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
    'm', 'n', 'p', 'q', 'r', 's', 't', 'u',
    'v', 'w', 'x', 'y', 'z', '0', '1', '2',
    '3', '4', '5', '6', '7', '8', '9' } ;
    String pwd = "" ;
    while( pwd.length() < 10 )
    pwd += letters[ (int)( Math.random() * letters.length ) ] ;
    this.Passwd = pwd;
    i successfully compile my java file. and try to test it by writing a jsp file.
    here is my jsp code
    <html>
    <head>
    <title>
    Try retrieving password
    </title>
    </head>
    <body>
    <jsp:useBean class"autogenerate.GeneratePwId" id="bean0" scope="page"/>
    <%=bean0.getPasswd()%>
    </body>
    </html>
    but i encounter this error
    org.apache.jasper.compiler.ParseException: /jsp/GetPasswd.jsp(7,18) Attribute class has no value
    anyone can teach me how to solve this problem?
    thanks a alot!

  • How can I generate random password

    Hello...
    I use oracle 10g for windows,,,I have an employee table , there are a lot of colunms , their names are employee_name , employee_id ,employee_pass .....
    employee_pass colunm is empty
    I want to generate random password for employee_pass colunm
    How can I generate random password for employee_pass colunm
    thanks
    omer faruk akyuzlu
    in Turkey

    SQL>  exec dbms_random.seed(to_char(sysdate, 'sssss'))
    PL/SQL procedure successfully completed.
    SQL> select dbms_random.string('X', 8) from dual
      2  /
    DBMS_RANDOM.STRING('X',8)
    4YT1H150
    SQL> select dbms_random.string('X', 8) from dual
      2  /
    DBMS_RANDOM.STRING('X',8)
    WIA3QCIP
    SQL> Please be aware that storing the actual passwords in a the EMPLOYEES table is a very bad idea. Oracle has a pretty good password implementation. It's not perfect but it's a darn site better than hand-rolling our own.
    Cheers, APC

  • How to generate random letter?

    i know how to generate random numbers but is there anyway to generate random letters? or colors?
    thanks in advance..

    marufai wrote:
    -uj-
    as i'm new in java...can u show me how to make random number from array list?
    i tried but it seem long
    ArrayList ma = new ArrayList();
         ma.add("A");
         ma.add("B");
         ma.add("C");          
         ma.add("D");          
         ma.add("E");
         num = gen.nextInt(5);
         System.out.print("" + ma.get(num) );
    so if i wan generate btw A to Z am i suppose to type A to Z out?
    Edited by: marufai on Sep 24, 2007 12:32 PMI like uj's method since it's more extensible, even though it's a little more work up front.
    If you have a range, say A to Z, then loop over the characters in that range, adding them to the list.
            List<Character> list = new ArrayList<Character>();
            for (char index = 'A'; index <= 'Z'; index++) {
                list.add(index);
            }Do that for all of the ranges that you want to add to the possibilities, and then choose random numbers between 0 and the length of the list.

  • How to generate random numbers from 1 to 5

    How to generate random numbers from 1 to 5   
    -1110340081
    Solved!
    Go to Solution.

    (You should not mark a post as solution unless it actually contains a solution to the original problem)
    Do you want to share your code? Did you test to make sure that all numbers equally probable?
    LabVIEW Champion . Do more with less code and in less time .

  • Anyone know how to generate random midi in real time? part 2

    anyone know how to generate random midi in real time?
    http://discussions.apple.com/thread.jspa?messageID=11342321
    This article was archive so I can't reply to this, but I wanted to bring this back up.
    As Christian pointed out on converting your notes to P-Press, then random DataByte 1 then convert back to a Note...
    I used this approached but was able to add in a macro I created to save the generated random DataByte 1 so that when the Note OFF message came around, I can apply that saved random DataByte 1 to the Note OFF in question.
    One thing I did notice when working this out was there's 2 differences in processing the messages when it comes to using a MIDI Input Device or a MIDI Performance (midi file).
    After I was able to figure this out, now I can randomize on notes using either of the 2 Inputs.
    While randomize notes probably won't sound nice to the ear, I apply another macro I created and I'm still adding too, and that's Music Scales.
    So while I randomize notes, when applied to this last macro, the random notes now get mapped to notes in a music scale of your choosing.
    This link shows what I did.
    http://www.digimixstudios.net/RandomizeNotesUseScales/
    I'm currently in the process of creating video tutorials in breaking down the whole process but I wanted to share what I have and see if there's any interested in this.
    Remember, this is just one approach and I hope it gives others ideas to work off of.

    anyone know how to generate random midi in real time?
    When I used to drink a lot... this was no problem at all!
    pancenter-

  • Generate Random Password by policy

    Hey guys,
    I'm trying to put together some code to randomly generate a password for new users that would match up with the user's associated password policy. I have this code mapped as a entity adapter on the pre-insert. The problem i am having is trying to retrieve the password policy that is associated with the new user.....the tcPasswordOperationsIntf utility class has a method called getUserPasswordPolicy which takes the usr_key as an argument.....but since the user hasn't been created yet the method fails with an usr_key not found error.
    anyone know how i can get the password policy for a new user? has anyone done anything like this before?
    Thanks in advance!

    Well if you are trying to set the password for the Users created in OIM then the password policy must be attached to Xellerate Users resource object. So you have an option of fetching the password policy using another API getObjectPasswordPolicyDescription of the same interface. You need to pass the Object Key in this case. This must return the ResultSet for the same thing you are expecting.
    The you can validate the password accordingly.
    Thanks
    Sunny

  • How to generate random numbers in a range?

    Hello. i am having trouble finding out how to generate a random number in a certain range. For example i have an array of 100 elements and i want to access one of the elements between 50 and 60, however i cannot find how to generate a random number between these two values.
    Thanks in advance

    java.util.Random.nextInt(int)
    Note that you can get a number between 0 and (max -
    min), exclusive. Then add min, and you've got your
    number.Obviously you didn't read this. It says to get a number between 0 and (max - min) which is actually what you did. But after that you need to add min. The first step would get a number in between 0 and 5. When you add 20 you'd get a number between 0+20=20 and 5+20=25.

  • Parameterized Active Sync Form generating random password

    Hi im looking for an sample of an Parameterized Active Sync Form which generates a random password.
    Thanks!
    Michael

    --I think password from AD not put in to activeSync.
    --Why?
    You cannot change the user's password from the activeSync RA. The password is encrypted in Active Directory and you can't decrypt it.
    You can read the Idm Resources Reference - Active Directory. There's a table with all the supported fields; the userPassword field is write-only.
    If you want to take the AD password and send it to IDM, you want to use Password Sync.
    Good luck

  • How To generate random activation code

    Hi Guys
    It might be a very simple question for most of you. I've seen many websites when you register, they send you an email with an activation code.
    It kind of looks like : XA432G2DGR343
    How do we generate something like this in Java. I know we can generate random numbers? Any tips on how to go about it.
    Thanks

    gubloo wrote:
    It might be a very simple question for most of you. I've seen many websites when you register, they send you an email with an activation code.
    How do we generate something like this in Java. So let me see if I have this straight. You are asking us to help you create a program, one that allows you randomly generate activation codes, and with these codes you will try to crack into websites where you haven't registered for or where you possibly haven't paid some entrance fee? Is this correct or am I missing some basic element of logic here? If I'm wrong, please correct my mistake. If I'm right, then you can go to h&#101;ll.

  • How to generate random sequence numbers

    Hello experts
    Iu2019m writing a custom program and pulling data from VBAK & VBAP. As per requirement I also need to generate a sequence number randomly and finally store all data in text file and upload at server. The hiccup is I donu2019t know how to generate sequence numbers. Can somebody please show me how I can accomplish it?
    Thanks a lot in advance

    Find the below code,
      data: lv_range type datatype-char0128.
      call function 'RANDOM_C'
        exporting
          len_min   = 20
          len_max   = 20
          char_min  = 1
          char_max  = 20
        importing
          rnd_value = lv_range.
    LV_RANGE param will have a random value..
    If you need number you can use the FM "RANDOM_I4"
    Thanks,
    Prathap

  • HOW TO GENERATE RANDOM MEANINGFUL STRINGS ?

    Friends,
    How do I generate random meningfull strings ? I know how to generate strings randomly but I want to generate meaningfull names. The length is not important. Please help me in this matter as I have to implement this soon.
    Thanks in advance
    Ankit.

    Thanks for reply,
    I want to generate any string randomly and also want to make sure that it is meaningfull name. I can use Random(0n class to generate random number then convert according to ascii table to char and concat these generated chars to have string but then it is not meaningfull string, it could be anything. I want the string to be meaningfull too.(any word or name in english language). I don't want to pick up already generated word or names from list randomly(i think this is what you are thinking)

  • How to generate random strings

    Gday all,
    So I have to create a simple guessing game where the user guesses a 3 letter string that is randomly generated:
    "For each new game your program will generate three unique random numbers between 0 and 9
    inclusive, and convert them into a String of three characters in the range A to J. This String will be an
    input to a game, where the user tries to guess the correct letters in the correct order. Examples of valid
    input Strings would be, �JAD�, �ABC�, �IBE� and �EFG�. Examples of some invalid input Strings could be
    �abc�, �AAA�, �123�, �AdE� or �NME�."
    Just wondering how to create this random string? I know how to generate a random 3 char number (num = (int) (Math.random() * 1000)) but I dont know how to convert this into a corresponding string, as the instructions say.
    I know this is very basic, but any tips?

    I know how to generate a random 3 char number (num = (int) (Math.random() * 1000)) but I dont know how to convert this into a corresponding stringUse string concatenation (+ with one or two String operands).
    int i = 42;
    char ch1 = '*';
    char ch2 = '!';
    String str = "foo";
        // the System.out.println() is not important
        // in each case a string is being created and printed
    System.out.println("" + i);
    System.out.println("2 times i = " + (2 * i));
    System.out.println(i + "*2=" + (2 * i));
    System.out.println("" + ch1 + ch2); // hint, hint
    System.out.println(1 + 2 + "???");
    System.out.println("???" + 1 + 2);

  • How to generate random numbers that doesnt contain characters?

    How do we generate random numbers in ESB ROuting Service/ XSL transformation that does not contain characters. I have been using "orcl:generate-guid()" , but it contains some characters, so, I substring it to get only numbers. I dont want to take this risk and in future, my substring itself may contain characters.
    Has anybdy tried this before?
    Thanks,

    If the goal is to have a pseudo random number then consider using the translate function to replace the occurances of the A - E characters with another digit. For example:
    translate(orcl:generate-guid(),'0123456789ABCDEF','0123456789123456')
    This will produce a 1 for A, 2 for B, etc. While not a valid hex to decimal conversion of the GUID value, it does get around the hex issue and might be sufficient for your purposes.
    I would perform a large sample test to see just how unique the values end up being.
    As for why hex is used, well GUID's are most commonly written in text as a sequence of hexadecimal digits such as: 3F2504E0-4F89-11D3-9A0C-0305E82C3301. i.e. 128 bits represented in 32 characters formatted into 5 sections.
    Hope this helps,
    Peter

Maybe you are looking for

  • Remotely Control Windows 7 Home Premium

    Hey, So this is my problem: I've got two computers at home. One's a Mac and the other is a Wndows 7 Home Premium machine. I have Lion Server coupled with ARD 3 and need to remotely control the Windows computer. I have installed VNC 4 (on Windows) but

  • Unable to download library books to my nook

    when i try to download a book to my nook from my local library i get a message saying i do not have authorization, please help

  • ExecuteToStream

    with ExecuteToStream for an XmlType Query (against a non-xml table) I get data back as what appears to be UTF-16. Can I change this to UTF-8 ? Or ASCII ? thanks R.

  • In what order are root hint DNS servers used?

    Hey guys, I was wondering how the list of root hints were actually used when the DNS server performs iterative queries.  Since it's a list that seems to be in alphabetical order, does it simple use a.root-servers.net. first until it is unavailable, a

  • Laptop breaks down after new BIOS installation

    Hi , My laptop HP 2000 - 2d11x is  nearly a year old now. My problems started last month when my laptop started overheating and shutting down randomly. Now my laptop is completely unusable. I do not know what happened to it but I suspect that the inc