Sheridan Wendt
  • Home
  • Technology
  • Business
  • Music
  • Adventures
  • Resume
  • Contact

Technology

How to Execute PowerShell Scripts with Task Scheduler

5/10/2019

Comments

 
Are you looking for a way to execute PowerShell scripts based on triggers such as time, events, or at startup? This article will demonstrate how to execute PowerShell scripts with the Task Scheduler. 
Picture
1. Create Your Script
For this article we're going to use a very basic PowerShell script that will ping a local network device. This can be automated in other ways, but the purpose of this article is to demonstrate how to trigger PowerShell scripts.

Here are the contents of my script called ping.ps1

     ping 192.168.0.1
2. Create Your Task
Open Task Scheduler by going to
Start > Run > 
taskschd.msc. 
​
​

Picture
Then right-click the white background and select Create Basic Task. Alternatively, in the menu select Action > Create Basic Task
Picture



Next type a name and description for the task as shown below and click Next. 
Picture



​After naming the task, we will select a Trigger for the task. In this case, we'll select When the computer starts. As the description implies, this task will run every time the computer is turned on.  
Picture


Next up we'll configure the action. This part can be tricky so be sure to double check for typos.

For this task the Action will be to Start a Program. This is what will start PowerShell. 

In the Program/script field, type powershell. 

In the Add arguments (optional)  field, we will need the location of the script and an argument for the Execution Policy depending on how your Execution Policy is currently configured. More on Execution Policies.

For the purposes of this article, paste the text below and be sure to update the location of your script. 
​
     -ExecutionPolicy Bypass C:\Windows\Powershell\ping.ps1
Picture

Click Next and Finish to save your new task.



3. Test Your Task
Now we will test to make sure our task works. Simply right-click the task, select Run, and your script will execute.  If the script runs too fast to visually see it execute, the Last Run Time or History tab can be used to verify successful run time. History is a great place to troubleshoot as well if issues are experienced. 
Picture
Picture
Picture
Comments

    Repositories

    PowerShell
    SQL

    Author

    Sheridan's interests are in technology, business, music, and adventures

    View my profile on LinkedIn

    RSS Feed

    Categories

    All
    Alerts
    Azure
    Business Intelligence
    Data Visualization
    Notifications
    Photo Frame
    PowerShell
    Raspberry Pi
    Scripting
    SMS
    SQL
    Technology
    Virtualization
    VMWare

    Business

    Archives

    June 2019
    May 2019
    September 2018
    May 2018
    April 2018
    March 2018
    February 2018
    December 2017
    September 2017
    July 2003

Powered by Create your own unique website with customizable templates.
  • Home
  • Technology
  • Business
  • Music
  • Adventures
  • Resume
  • Contact