No announcement yet.

two powershell scripts, wait command?

  • Filter
  • Time
  • Show
Clear All
new posts

  • two powershell scripts, wait command?

    Hoping someone can help,

    I have two PS scripts, I need the first one to finish before the second one begins, is this possible?
    The reason I require this is

    I am in a middle of an Exchange 2003 to Exchange 2007 tranisition.

    I have a Powershell script that moves the mailboxes to a particular message store, the problem is then I have to manually move them to a different message store.

    If I have multiple scripts, I could put the users into the correct script for that message store so it would save me manually moving them after.

    I am very much new to scripting, the only other way I thought I could do it is if I scheduled each script to run at a particular time, but that isn't ideal.

  • #2
    Re: two powershell scripts, wait command?

    Have a look at that - however, you'd need to make sure that any previous task is foreground processing, rather than running the background
    Ie, no point kicking off a mailbox move, then the other script, if the mailbox move isn't complete.

    So you'd need some way of knowing the first task is complete
    Please do show your appreciation to those who assist you by leaving Rep Point


    • #3
      Re: two powershell scripts, wait command?

      Invoke-expression doesn't spawn a background thread. Unless the first script spawns a background thread, you could just run both scripts form the Powershell command line using semicolon to like so:

      This way script1 will be executed and after it is done, script2 will be run.