Solved

How to run PowerShell scripts with arguments in Task Scheduler ?

Posted on 2012-12-21
2
2,490 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 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

730 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