none
notepad edit .ps1 file can not run RRS feed

  • Question

  • ****I didn't use Chinese word in my script*****

    When I edit script by using echo, the script works well.

    But after I edit the .ps1 file by using notepad, no matter what I edit even just one single word, it will show the same error:

    At C:\Users\tliu\Desktop\test.ps1:1 char:95
    + ... 23ed21ac86a7e9e6a0c66bf31eb    b40ef6`>m<8:;==i t# "q&"!.,~.,&/B ...
    +                                                                  ~
    Missing expression after ',' in pipeline element.
    At C:\Users\tliu\Desktop\test.ps1:1 char:95
    + ... 3ed21ac86a7e9e6a0c66bf31eb    b40ef6`>m<8:;==i t# "q&"!.,~.,&/B ...
    +                                                                 ~
    The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double
    quotation marks ("&") to pass it as part of a string.
    At C:\Users\tliu\Desktop\test.ps1:3 char:12
    + t#$qvr%s~|s{),yeef50f3fhh99djj=V]RUP]P]\U\^AAJGCOHBJ獯板娑嗑砑 ...
    +            ~
    Missing closing '}' in statement block or type definition.
    At C:\Users\tliu\Desktop\test.ps1:3 char:13
    + t#$qvr%s~|s{),yeef50f3fhh99djj=V]RUP]P]\U\^AAJGCOHBJ獯板娑嗑砑 ...
    +             ~
    Unexpected token ')' in expression or statement.
    At C:\Users\tliu\Desktop\test.ps1:3 char:15
    + t#$qvr%s~|s{),yeef50f3fhh99djj=V]RUP]P]\U\^AAJGCOHBJ獯板娑嗑砑 ...
    +               ~
    Missing expression after unary operator ','.
    At C:\Users\tliu\Desktop\test.ps1:3 char:15
    + ... $qvr%s~|s{),yeef50f3fhh99djj=V]RUP]P]\U\^AAJGCOHBJ獯板娑嗑砑负唤 ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Unexpected token 'yeef50f3fhh99djj=V]RUP]P]\U\^AAJGCOHBJ獯板娑嗑砑负唤介狋ⅠΒ‘Ο枔捖枙斊灅潥蜗葲宰
    呇儏弬墎屴剭輱簦ゑ鲵ン篼┈?邋娴版虫梃构潢杲倗喼菀招菪輳苷苻亮愂敲敀先熉樖湞c51dg7a?l=9;:<<h!u"!#p'#' in expression
    or statement.
    At C:\Users\tliu\Desktop\test.ps1:7 char:10
    + ]^w 'ruq&p}px*/z|ffe63e0ekk::gii>U^QVS^S^ _V_]BBID@LKA ...
    +          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The string is missing the terminator: '.
        + CategoryInfo          : ParserError: (:) [], ParseException
        + FullyQualifiedErrorId : MissingExpression


    • Edited by tongzhou Tuesday, April 25, 2017 10:36 PM
    Tuesday, April 25, 2017 9:46 PM

Answers

All replies

  • You cannot use Chinese characters in a script file.  Perhaps your encoding is set wrong.  It should be Unicode or ANSI.

    \_(ツ)_/


    • Edited by jrv Tuesday, April 25, 2017 9:56 PM
    Tuesday, April 25, 2017 9:54 PM
  • I did not use Chinese characters. Even the same script, as long as i open with notepad, it will show these errors.

    By the way, the encoding is Unicode.


    • Edited by tongzhou Tuesday, April 25, 2017 10:37 PM
    Tuesday, April 25, 2017 10:10 PM
  • The file may be corrupt.  Start with a new file and type the code in one line at a time and test.


    \_(ツ)_/

    Tuesday, April 25, 2017 10:17 PM
  • Not work, still have the same error.. even only two words "echo hello"
    Tuesday, April 25, 2017 10:22 PM
  • As I noted - you cannot use a Chinese character set with PowerShell.

    Did this ever work?


    \_(ツ)_/

    Tuesday, April 25, 2017 10:29 PM
  • Can you try to think out of the Chinese character? 
    Tuesday, April 25, 2017 10:40 PM
  • What character set is your system set to?


    \_(ツ)_/

    Tuesday, April 25, 2017 11:01 PM
  • English.

    I found the problem. I forgot to close the encryption secure tool so it encrypts file automatically.

    Thank you so much.

    Tuesday, April 25, 2017 11:05 PM