EDIT: Thank you everyone for the help! The answer was to literally delete the "-" in the script and retype. I copied Set-DNSClientServerAddress "Ethernet" -ServerAddresses ("1.1.1.1","8.8.8.8") from a different stackoverflow answer, and apparantly the dash was the wrong kind of dash.
can anyone help me figure out why this simple script is giving an error, when running the same exact command by copy and pasting it into an existing powershell window works fine?
$confirmation = Read-Host "Change DNS?"
if ($confirmation -eq 'y')
{
Set-DNSClientServerAddress "Ethernet" –ServerAddresses ("1.1.1.1","8.8.8.8")
}
pause
When that is ran manually by copy and pasting into Powershell, it works perfectly.
However, when saving that code into a test.ps1 file, and then right clicking on the file to Run with Powershell, it gives this error:

-in-ServerAddresses.–(EN DASH,U+2013) character instead of the usual ASCII-range-(HYPHEN-MINUS,U+002D) beforeServerAddresses. That in itself is not a problem, but because your UTF-8-encoded script file lacks a BOM, it is misinterpreted by Windows PowerShell, which sees the–asâ€. The solution is to save your script file as UTF-8 with BOM; see this answer to the first linked duplicate.