Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to run PowerShell scripts with arguments in Task Scheduler ?

Posted on 2012-12-21
2
Medium Priority
?
2,812 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 18

Accepted Solution

by:
Learnctx earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.

972 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