locked
Launch 32-bit Powershell script from a share in scheduled task? RRS feed

  • Question

  • Hi,

    I'd need to run a 32-bit powershell in a scheduled task. The script itself is on a share. That are 2 things to tackle, first thing I tried with running 

    %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe

    in the program/script properties of the scheduled task , then I give the parameters

    -NoProfile -WindowStyle Hidden -command ". .'\\myshare\main.ps1 -parameterfile \\myshare\myparameterfile'" but I get error 0x1 in the scheduled job

    Running the ps1 from a 32-bit powershell works fine (although it pops up with 'run once' each action in the script).

    So my questions:

    *howto debug the problem in the scheduled task? 

    *isn't there a way to "mount" the share so it doesn't throw the security warnings notifying that it is a non trusted location?


    Jan Hoedt

    Monday, November 5, 2018 10:57 AM

Answers

  • Why not use the -File parameter of powershell.exe to run a script file?

    Run: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe

    Parameters: -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "d:\path\script name.ps1" ...

    After the script name, put the parameters needed for the script. You can use named parameters.

    (Make sure that -File is at the end. The powershell.exe /? help text tells us this explicitly.)


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Bill_Stewart Thursday, January 3, 2019 4:00 PM
    Monday, November 5, 2018 6:07 PM

All replies

  • Once again you forgot that you cannot pass named parameters on a command line.  Pass all parameters by position.

    Also you must be sure that there are no commands that will produce a prompt.  Be sure you manage that first.


    \_(ツ)_/

    Monday, November 5, 2018 11:27 AM
  • Why not use the -File parameter of powershell.exe to run a script file?

    Run: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe

    Parameters: -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "d:\path\script name.ps1" ...

    After the script name, put the parameters needed for the script. You can use named parameters.

    (Make sure that -File is at the end. The powershell.exe /? help text tells us this explicitly.)


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Bill_Stewart Thursday, January 3, 2019 4:00 PM
    Monday, November 5, 2018 6:07 PM