none
Do Untill loop using Powershell RRS feed

  • Question

  • Hi All,

    I have a requirement to

    1.move a Database from one DB to another DB

    2. Wait till the status is completed

    3.REmove the Move request from User

    4.Move to next workflow.

    I have used the Exchange AD IP (MS Orchestrator) to Create a new Moverequest and I have a put a PS script to check the status till its completed.

    The Problem i face it when i run them it quits from the loop and executes the next workflows to remove the Moverequest which fails as the status shows that its still in progress. Can someone please guide where I am going wrong. 

    $Stoploop = $false
    [int]$Retrycount = "0"
     
    do {
     try {
     $Move = Get-MoveRequest -Identity 'Identity'
     $Request = $Move.Status
     If ($Request -eq 'Completed')
     {
     $Stoploop = $true
     }
     }
     catch {
     if ($Retrycount -gt 10){
    
     $Stoploop = $true
     }
     else {
     If (($Request -eq 'Inprogress') -or ($Request -eq 'Queued') -or ($Request -eq 'CompletioninProgress'))
     {
     Start-Sleep -Seconds 30
     $Retrycount = $Retrycount + 1
     }
     }
     }
    }
    
    Until ($Stoploop -eq $false)


    Justin


    • Edited by JS2206 Thursday, June 21, 2018 8:49 AM Removed
    • Moved by Bill_Stewart Tuesday, July 31, 2018 2:59 PM Abandoned
    Thursday, June 21, 2018 8:49 AM

All replies