# Results shows only on second run

**URL:** <https://forums.powershell.org/t/results-shows-only-on-second-run/17540>\
**Category:** PowerShell Help\
**Created:** [September 14, 2021, 7:37am UTC](https://forums.powershell.org/t/results-shows-only-on-second-run/17540 "2021-09-14T07:37:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dady](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/dady/32/1710_2.png) [@dady](https://forums.powershell.org/u/dady)\
**Post date:** [September 14, 2021, 7:37am UTC](https://forums.powershell.org/t/results-shows-only-on-second-run/17540/1 "2021-09-14T07:37:15Z")

</div>

Hi all,

Like the subject says, when i run the code the first time, i’m not getting results. But if i’ll run from the menu the code again the results will be shown. Why is that?

Here is the code:

```auto
CLS
    Write-Host -ForegroundColor Yellow "Getting Server list and information..." 
    $ExchServers = Get-ExchangeServer
    foreach ($Server in $ExchServers) {
        Get-Queue -Server $Server
    }
    Write-Host "`n1. Run again `n2. Return to Main Menu"
    $menuresponse = read-host [Please Enter Selection]
    Switch ($menuresponse) {
        "1" {Show-Queue}
        "2" {Main-Menu}
    }

```

Thanks in advance

---

<div class="post-metadata">

**Author:** ![ShaunBlake](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/shaunblake/32/1273_2.png) [@ShaunBlake](https://forums.powershell.org/u/ShaunBlake)\
**Post date:** [September 16, 2021, 4:44am UTC](https://forums.powershell.org/t/results-shows-only-on-second-run/17540/2 "2021-09-16T04:44:36Z")

</div>

Umm… @dady I dunno (being a luddite, noob, and a bit handicapped in the wetware area) but I suspect it has something to do with the environment where you test the code vs. where you invoke it.

As it seems that it produces the proper (to be determined, I suppose) results, perhaps you might adjust your protocol to (as you did) test in the GUI, but verify in situ? jus’ sayin’ (Luddite an’ all that)

---

<div class="post-metadata">

**Author:** ![dady](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/dady/32/1710_2.png) [@dady](https://forums.powershell.org/u/dady)\
**Post date:** [September 20, 2021, 9:28am UTC](https://forums.powershell.org/t/results-shows-only-on-second-run/17540/3 "2021-09-20T09:28:22Z")

</div>

Thanks but i didn’t quite understand what did you mean by “protocol”?  
I’m running this script from the PowerShell console in my computer which is connected to the same network\domain where the exchange server is.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:21pm UTC](https://forums.powershell.org/t/results-shows-only-on-second-run/17540/4 "2024-05-16T20:21:21Z")

</div>

Closed on May 16, 2024, 8:21pm UTC


