I recently encountered problems when testing unattended Windows deployment.
A PowerShell script for setting up ShellLauncher did not seem to run.
Found this log message:
C:\Windows\system32>Powershell.exe –ExecutionPolicy RemoteSigned -NoProfile -NonInteractive c:\Install\PowerShell\ShellLauncher-setup.ps1 –ExecutionPolicy : The term '–ExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or ope rable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again
This puzzled me because –ExecutionPolicy seemed correct.
When running the script manually from cmd.exe the cause of the problem became apparent:
ûExecutionPolicy : The term 'ûExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I examined which character was actually used instead of minus. It was – (en dash, 150) in Windows code page 1252 Latin 1 (ANSI).
PowerShell expects minus for options and interprets en dash as part of a cmdlet, function, script or program name.
Conclusion
No matter what code page and encoding is used many characters look similar to human eyes, but not to a computer.
If you encounter syntax problems for code or data that looks correct, I recommend checking the encoding and the actual character bytes with a hex editor.