Sunday, July 10, 2011

Unrecognized token in source text : powershell

While excecuting powershell script where you require charectors like @ , $ and * to be passed as parameters you can get following error .

Even IF you use a double quoted string will still need to use tic marks to escape the character.
(e.g. `@, `$ ).


Unrecognized token in source text.
At line:1 char:88
+ & 
...................................


-NoExit
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : UnrecognizedToken


 

5 comments:

  1. i have the same error.you can make them between ' ' for no error
    For example .......npm install '@types/lodash' --save-dev

    ReplyDelete
  2. i need help :(

    Import-Csv "C:\a2.csv" | foreach {Set-ADUser -Identity $_. SamAccountName -add @ {Proxyaddresses= $ _. Proxyaddresses -split ","}}

    ReplyDelete
  3. I need help. I am trying to install
    npm install @ant-design/icons
    But could not understand what the issue is.

    ReplyDelete