Infinite Loop Inside Process

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 3 years, 3 months ago.

  • Author
  • #24320

    Malik Amaduddin

    I want to process each server in the pipeline in an infinite loop. However it is not working. I have the following code which is only returning the result of one (the first one) value from the pipeline.

    ForEach ($HubServer in $Server)
    $CurrentDateTime = Get-Date
    Write-Host "Queue From " $Server " @ " $CurrentDateTime
    Get-Queue -server $Server | select-object Identity, DeliveryType, Status, MessageCount, NextHopDomain, LastError, LastRetryTime | Ft -AutoSize
    Write-Host "Press Ctrl+Break to quit"

    Start-Sleep -s 5



    I would appreciate any ideas on how it can be done.

  • #24331

    Don Jones

    Your ForEach loop suggests that $Server contains more than one item, and you are using $HubServer to contain one item at a time. However, inside the loop, you haven't used $HubServer. You continued to use $Server, which isn't what I would expect.

You must be logged in to reply to this topic.