Strange Powershell 5.0 behaviour

This topic contains 5 replies, has 3 voices, and was last updated by  Richard Siddaway 2 years, 10 months ago.

  • Author
  • #28235


    $NICs = Get-WmiObject Win32_NetworkAdapter | Where-Object {$_.PhysicalAdapter -eq $true}

    $NICs | Select-Object Name, DeviceID

    $NICnumber = Read-Host "`nSelect Network Adapter"

    When running the code above on PowerShell 4.0 it works normally, but when I try it on Powershell 5.0 the list of network cards isn't displayed. Somehow Read-Host screws up the output, I also get the same result with "[Console]::ReadLine()". Is this a bug or what?

  • #28236

    Richard Siddaway

    I can't reproduce your problem. Running your code on PowerShell 5 on Windows 10 RTM works for me

  • #28237


    Strange, I got the same result on two different Machines.

  • #28238

    Daniel Krebs

    I can reproduce it on Win10 RTM. The output of the Select-Object gets displayed after the Read-Host prompt instead of before.

    You should submit a bug report via Connect –

    A workaround would be to use Format-Table to get the correct output.

    $NICs = Get-WmiObject -Class Win32_NetworkAdapter |
    Where-Object { $_.PhysicalAdapter -eq $true }

    $NICs | Format-Table -Property DeviceID, Name

    $NICNumber = Read-Host "`nSelect Network Adapter"

  • #28241

  • #28242

    Richard Siddaway

    Its a little more complicated than you stated as it works fine for me in the PowerShell console but I can reproduce the problem in ISE

You must be logged in to reply to this topic.