Solved

How to run PowerShell scripts with arguments in Task Scheduler ?

Posted on 2012-12-21
2
2,239 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
2 Comments
 
LVL 14

Expert Comment

by:brendanmeyer
Comment Utility
0
 
LVL 16

Accepted Solution

by:
Learnctx earned 500 total points
Comment Utility
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Join & Write a Comment

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of 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…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now