Unable to run powershell script in background using task scheduler?

Welcome Forums General PowerShell Q&A Unable to run powershell script in background using task scheduler?

Viewing 2 reply threads
  • Author
    Posts
    • #269585
      Participant
      Topics: 6
      Replies: 5
      Points: 54
      Rank: Member

      Hi,

      I am unable to run a powershell script in the background using task scheduler. No matter what account I use it’s not working. The command to start the script works if I execute it directly in powershell.

      The command to run in powershell is this one:

      start-process powershell -WindowStyle Hidden -ArgumentList “\\my_server\Wake_On_Lan\Wake_on_lan_web_server.ps1”
      The command in task scheduler:
      The script is small web server in powershell:

      Am I missing something? I need the script to run while I am not logged in.

      • This topic was modified 3 weeks, 6 days ago by Carl.
    • #269591
      Participant
      Topics: 17
      Replies: 1869
      Points: 3,631
      Helping Hand
      Rank: Community Hero

      Try moving the script to the local server. If it works, then you are most likely dealing with a double-hop issue by executing with credentials on the local server and then trying to execute a script via a UNC path which require authentication.

    • #269597
      Participant
      Topics: 6
      Replies: 5
      Points: 54
      Rank: Member

      I just did and it’s working.

      I have replaced “\\my_server\Wake_On_Lan\Wake_on_lan_web_server.ps1” with “D:\Wake_On_Lan\Wake_on_lan_web_server.ps1”

      Thanks a lot!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.