Run any PowerShell Script as a Windows Service with AlwaysUp

How to Run any PowerShell Script as a Windows Service with AlwaysUp

Start your PowerShell script (*.ps1) when your PC boots. Keep it running 24/7, or schedule it to re-run every few minutes.

Windows PowerShell is Microsoft's powerfull command-line interface featuring built-in support for accessing WMI and COM objects.

To set up a PowerShell script to run as a Windows Service with AlwaysUp 6.0 and later:

  1. Download and install AlwaysUp, if necessary.

  2. Start AlwaysUp.

  3. Select Application > Add to open the Add Application window:

    Add Application

  4. On the General tab:

    • In the Application field, enter the full path to the PowerShell executable, powershell.exe. On our 32-bit Windows 7 machine, this is:

      C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

    • In the Arguments field, enter the full path to your PowerShell script. We have chosen our sample script, C:\PowerShell\CleanLogFiles.ps1.

    • In the Name field, enter the name that you will call the application in AlwaysUp. We have used My PowerShell Script but you can specify virtually anything you like.

    PowerShell Windows Service: General Tab

  5. Click over to the LogOn tab and enter the user name and password of the account that can run the script normally. This is particularly important if your script accesses resources that are not available to every account.

    PowerShell Windows Service: LogOn Tab

  6. By default AlwaysUp will restart your PowerShell script immediately after it exits. If you want to run it periodically, go to the Restart tab and specify when AlwaysUp should kick off the script. We have setup our script to run every hour, on the hour.

    PowerShell Windows Service: Restart Tab

  7. Click the Save >> button. In a couple of seconds, an application called My PowerShell Script will show up in the AlwaysUp window. It is not yet running though.

    PowerShell Windows Service: Created

  8. To run the script, choose Application > Start "My PowerShell Script". Note that it will not start until the next hour, as configured.

    PowerShell Windows Service: Running

    The PowerShell script is currently running in Session 0. On Windows XP and Server 2003, you can see it by logging on to that session. On Windows 7, Vista and Server 2008, you can see it if we go to Session 0 by selecting Tools > Switch to Session 0.

  9. That's it! Next time your computer boots, the PowerShell script will be launched immediately, before anyone logs on. We encourage you to explore the many other settings that may be appropriate for your environment.



PowerShell Script not working properly as a Windows Service?

  • From AlwaysUp, select Application > Report Activity > Today... to bring up a HTML report detailing the interaction between AlwaysUp and your application. The AlwaysUp Event Log Messages page explains the more obscure messages.
  • Consult the AlwaysUp FAQ for answers to commonly asked questions and troubleshooting tips.
  • Contact us and we will be happy to help!

Download & Try it Free!

Download AlwaysUp and Run as a Service Today! Version 9.7

4.6 MB Installer
  • Unrestricted 30-day trial for new users; upgrade for existing users
  • Windows 10/8.1/8/7/XP & Windows Server 2012 R2/2008/2003
  • How to Install | EULA
Our customers include...


Compatible with Windows 10 (32 & 64-bit)

Windows Server 2012 Certified (32 & 64-bit)

Windows 8 Compatible (32 & 64-bit)

Compatible with Windows 7 (32 & 64-bit)

Works with Windows Server 2008 R2 (32 & 64-bit)



Over 68,000 installations, and counting!
 
AlwaysUp is number 1! Run as a Service with AlwaysUp

Rock-solid for the past 10+ years!