Powershell writes Unicode to files by default; if you add the switch -Encoding ASCII then you can forget all the other tricks (I think)
1| % {Get-Random -Minimum 2 -Maximum 222 } | Out-File -FilePath D:\number.txt -Encoding ASCII
It worked for me. SET /P read the value to %out% and TIMEOUT /T %out% read the value properly. Please try it.