Looping a script RRS feed

  • Question

  • Hello, we need to create about 1500 shared mailboxes. We were hoping to use a script to do that work. The question is, is there a way to execute the script to re-run automatically a certain number of times and to add a number at the end of the mailbox name, i.e mailbox0001, mailbox0002, mailbox0003, etc...
    Thanks for any help.
    • Moved by Bill_Stewart Monday, July 29, 2019 8:07 PM This is not "scripts on demand"
    Friday, March 22, 2019 1:41 PM

All replies

  • Yes it is very easy to do. Find someone in your organization who has programming experience and ask them to help you. 
    Friday, March 22, 2019 2:03 PM
  • for($i = 1;$I -le 1000;$I++){

    Before asking questions in a technical forum you will need to learn the basics of the technology in the case PowerShell.

    This is not a customer service forum or a sales support forum.

    As recommended above you can find technicians in your company or you can hire a consultant.

    The simple answer is "yes" you can do these things using basic programming methods.  Any trained technician in  your company should be able help you with this basic question.


    Friday, March 22, 2019 2:48 PM
  • Hi,

    Here is an example that may help you out.

    $TimesToRun = 1500
    $Numbers = (1..$TimesToRun)
    ForEach($Number in $Numbers){
        "mailbox" + '{0:d3}' -f $Number



    • Proposed as answer by CITLead Friday, March 22, 2019 3:07 PM
    Friday, March 22, 2019 3:06 PM