Auto run of PS Script

Welcome Forums General PowerShell Q&A Auto run of PS Script

Viewing 2 reply threads
  • Author
    Posts
    • #98283
      Participant
      Topics: 23
      Replies: 48
      Points: 285
      Helping Hand
      Rank: Contributor

      Hi Team,
      Need an assistance for auto executing PowerShell script (ps1). I know that for security reason PS scripts are not run automatically, but yet if you find any way out please guide me.
      I tried using batch file, but it’s failed actually. The batch file opening the prompt of PowerShell but after that nothing executed. I’m planning for creating a schedule task, but yet feeling that will not work.
      So if any of you find any tricks for the same, please let me know.
      Thanks in Advance.
      Regards,
      Roy.

    • #98284
      Participant
      Topics: 5
      Replies: 2367
      Points: 5,981
      Helping Hand
      Rank: Community MVP

      That’s actually not a Powershell scripting issue. 😉 To run a Powershell script you should use a proper command line:

      Powershell.exe -ExecutionPolicy Bypass -NoProfile -File "\.ps1"
      • #98901
        Participant
        Topics: 23
        Replies: 48
        Points: 285
        Helping Hand
        Rank: Contributor

        Thanks, it works.

    • #98902
      Participant
      Topics: 2
      Replies: 513
      Points: 1,322
      Helping Hand
      Rank: Community Hero

      Alternately, you can elect to change the execution policy to permit scripts to run.

      Set-ExecutionPolicy RemoteSigned -Scope CurrentUser 
Viewing 2 reply threads
  • The topic ‘Auto run of PS Script’ is closed to new replies.