locked
Power Shell script - ParserError RRS feed

  • Question

  • Hello,

    I obtain a ParserError when I execute the PS script below:

    $computernames = (get-content “C:\computersList.txt”)

    cd "C:\WINDOWS\System32"

    foreach ($computer in $computernames){

    "c:\Users\toto\Downloads\psexec.exe" \\$computer /u "domain\user name" /p "pass" -c Cscript script.vbs

    }


    The error concerns the argument of psexec: \\$computer

    What is the correct syntax to use a variable ?

    Thanks in advance

    • Moved by Bill_Stewart Monday, March 2, 2015 8:38 PM Abandoned
    Tuesday, January 20, 2015 9:57 AM

All replies

  • Hi,

    Could you please put the error here.

    Regards,

    Tuesday, January 20, 2015 11:53 AM
  • Hi,

    Could you please put the error here.

    Regards,


    Resolved!

    The error was on :

    "c:\Users\toto\Downloads\psexec.exe"

    PsExec was not recognized. I just removed the quotes
    Tuesday, January 20, 2015 1:41 PM
  • Good, please mark this as answer and close the thread
    Tuesday, January 20, 2015 2:02 PM