How can we save ".PS1" file as ".Bat" file and schedule it using windows scheduler ?

  • Hi Experts,

    I am new to powershell.

    I have a ".ps1" file to be scheduled as batch file in windows task scheduler.

    C:\Windows\System32\WindowsPowershell\Powershell.exe -File "E:\Schedule\Test.ps1"

    The above command is working fine.

    But when I save it as ".bat" file and execute from windows command prompt, it throws errors like below.

    "'#' is not recognized as an internal or external command, operable program or batch file.".

    Get same error for all powershell commands.

    How can we save ".PS1" file as ".Bat" file and schedule it using windows scheduler ?

    Thanks in advance.

    San.

  • What if you put CALL at the beginning?

    like:

    CALL C:\Windows\System32\WindowsPowershell\Powershell.exe -File "E:\Schedule\Test.ps1"

  • Thanks.

    I scheduled it almost the same way as of now.

    Set following params in the schedule.

    Program/Script=powershell.exe

    Add arguments (optional)=process.ps1

    However, I would prefer to convert it as .bat file and schedule it.

    Thanks,

    San.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply