locked
Check Status until completed or failed RRS feed

  • Question

  • Hi 

    I have a requirement to check the status of a move request in Exchange and once completed move to the next step and i am using the below script for the task

    Do
    {
      sleep 10
    }
      Until((Get-MoveRequest -Identity 'ID').Status -eq 'Completed')

    Recently i have noticed that the script waits indefinitely as Status moves to 'Failed'. How can i incorporate such a condition to the script.

    Do
    {
      sleep 10
    }
      Until((Get-MoveRequest -Identity 'ID').Status -eq 'Completed' -or (Get-MoveRequest -Identity 'ID').Status -eq 'Failed' )

    The above exits the loop but it does not show whether the process was 'Completed' or 'Failed'. How can i achieve it. Please assist.


    Justin

    Thursday, February 7, 2019 6:08 PM

Answers

  • While(1) {
        $request = Get-MoveRequest -Identity 'ID'
        if($request.Status -match 'Completed|CompletedWithWarning|Failed'){break}
        Start-Sleep 10
    }
    $request.Status


    \_(ツ)_/

    • Marked as answer by JS2206 Thursday, February 7, 2019 6:41 PM
    Thursday, February 7, 2019 6:22 PM

All replies

  • While(1) {
        $request = Get-MoveRequest -Identity 'ID'
        if($request.Status -match 'Completed|CompletedWithWarning|Failed'){break}
        Start-Sleep 10
    }
    $request.Status


    \_(ツ)_/

    • Marked as answer by JS2206 Thursday, February 7, 2019 6:41 PM
    Thursday, February 7, 2019 6:22 PM
  • Thank you so much. It worked for me.

    Justin

    Thursday, February 7, 2019 6:43 PM