Solved

How to run PowerShell scripts with arguments in Task Scheduler ?

Posted on 2012-12-21
2
2,607 Views
Last Modified: 2012-12-26
I have a .ps1 script with arguments (means I run it under powershell: ./script.ps1 -timeframe 100 -filename c:/file -silent).

My question is, how can I create a scheduled task to run this script, or a .bat file to run this script, and to be able to schedule the .bat file...

Or actually any other suggestions how to schedule this script it would be great, I'm just not familiar with PowerShell yet.

Thanks!
0
Comment
Question by:V4705
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
Learnctx earned 500 total points
ID: 38715043
For Windows Server 2003 I do the following:
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noprofile -nologo -command "& 'C:\ScriptPath\script.ps1' -timeframe 100 -filename 'c:\file' -silent"

Open in new window

For Server 2008 and above it is much better at detecting parameters. Just enter the path to the PowerShell executable, and in the parameters field put:
-nologo -noprofile -timeframe 100 -filename 'c:\file' -silent

Open in new window

0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question