$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?
I can’t reproduce your problem. Running your code on PowerShell 5 on Windows 10 RTM works for me
Strange, I got the same result on two different Machines.
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 - http://connect.microsoft.com/powershell.
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”
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