As suggested in the comment information, the IP Address in the
ip.txt is probably preceded and/or succeeded by one or more new line (Cr/Lf) characters.
If you use the
Get-content will return all the lines including newline characters as a single string (
[String]). At the other hand, if you do not include the
Get-content will return all the lines as separate strings (
[String]), which might cause an issue in your case as well.
$myip=Get-content 'C:\Users\USER\Documents\ip.txt' -Raw $myip = $myip.trim() netsh interface portproxy add v4tov4 listenport=3390 listenaddress=0.0.0.0 connectport=3390 connectaddress=$myip
CLICK HERE to find out more related problems solutions.