Author Posts

April 16, 2015 at 1:51 am

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.

April 16, 2015 at 3:53 am

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.