This code is being run in pwsh 7, not PowerShell 5 and below.
If I run this code
while ($true) {
$Read = Read-Host
$Obj = New-Object Object
$Obj | Add-Member -MemberType NoteProperty -Name "Text" -Value $Read
$Obj
}
The first input is ignored, the second input returns both the first and second input at once, and the rest works as intended. How can the first input be returned BEFORE the second input?
This is a simplified version of a bigger project including objects of type System.IO.FileSystemWatcher
.
A simple code like
while ($true) {
$Read = Read-Host
$Read
}
Works as intended and will return whatever you typed each time you press "enter". This also works with HashTable and more.