Solved

How to run PowerShell scripts with arguments in Task Scheduler ?

Posted on 2012-12-21
2
2,356 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
ID: 38715040
0
 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Scheduled Tasks Tweak 5 32
Get processes with highest usage 2 21
Copying from excel I am getting extra text 11 44
Power shell script 2 11
You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

821 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