4

I have the following comment in a powershell script:

#ERROR: Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send.
#EXPLANATION: PowerShell calls uses TLS 1.0 for web requests by default. 
#             However, Exchange is expecting a higher level of TLS, so you need to tell PowerShell to use 1.2 instead of the default of TLS 1.0
​#SOLUTION(s): 
#             [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

when i run the script i get this error:

s : The term 's' 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.
At ps1:4 char:14
+ ​#SOLUTION(s):
+              ~
    + CategoryInfo          : ObjectNotFound: (s:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

why is it complaining about a comment?

if i remove (s) it then complains about SOLUTION itself...

1 Answer 1

5

You have it posted in your error log: + ​#SOLUTION(s):

There is a null character before the # in your code to the left of SOLUTION(s):, so it is reading the line into powershell. Just delete the row ​#SOLUTION(s): and retype it.

To check copy-and-paste the line into powershell console, should read out like below:

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

woah! how the heck is that even possible....i pressed backspace and there truly seemed to have been something there! but how?? everything aligns with the above comments...how do these null chars come from?
Sometimes our human hands can do weird things. Might have accidentally did an alt code - number pad somehow. It happens more often then you'd think.
but wouldnt there have to be a key typed in if i did that by mistake...i wonder if alt does like a milli centemeter of spacing that is barely recognizable
It is an encoding error so if you copied it from another file with different encoding or a site for the Solutions it might have been mistranslated with your clipboard or program. When I looked online it said that it was a encoding for UTF-8 being read by ASCII or Windows-1252 being turned into UTF-8 and having a incorrect character specification set.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.