User Creation Script RRS feed

  • General discussion

  • I've made a user creation script that is working perfectly, but I want to add some ease of use and better functionality. Right now, we can create a single user at a time but during the script, we need to force AD syncs to Azure which makes the script take 6-8 minutes to run. I'd like to add a do-while loop to allow multiple users to be made at the same time and I can force the sync for multiple users at once instead of waiting for a couple minutes to ensure the sync has completed.

    My biggest question is, how can I create multiple variables for different users through the do-while loop.


    First loop would be:


    Second loop would be:


    If I just do a do-while loop and not create new variables, won't it overwrite $User, $FName, etc or will it store them all?

    • Changed type Bill_Stewart Wednesday, July 26, 2017 7:34 PM
    • Moved by Bill_Stewart Wednesday, July 26, 2017 7:35 PM User's code reveals misunderstandings we can't correct in a forum
    Thursday, June 15, 2017 2:56 PM

All replies

  • Share the code you have which helps others to share some ideas. 

    Regards Chen V [MCTS SharePoint 2010]

    Thursday, June 15, 2017 3:05 PM
  • I think an introduction to arrays (collections) in PowerShell would be helpful to you.

    You don't need a variable $User and another variable $User2. A single variable, $Users, can contain a collection of objects. This is fundamental to how PowerShell works.

    I would very much encourage you to start by learning the fundamental concepts. This will help you greatly in avoiding misunderstandings and confusion.

    -- Bill Stewart [Bill_Stewart]

    Thursday, June 15, 2017 3:12 PM
  • Thanks
    Thursday, June 15, 2017 6:24 PM
  • Thank you, Chen. I don't have the time right now to sanitize over 250 lines of my script. I don't believe I need to share the code since I am just inquiring about generic array functions and how best to use them in this situation.

    I really do appreciate your willingness to help, but I don't think supplying the code will help the process.

    Thursday, June 15, 2017 6:26 PM