Infinite Loop Inside Process

Welcome Forums General PowerShell Q&A Infinite Loop Inside Process

This topic contains 1 reply, has 2 voices, and was last updated by

3 years, 10 months ago.

  • Author
  • #24320

    Points: 0
    Rank: Member

    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

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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.

The topic ‘Infinite Loop Inside Process’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort