![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to schedule a Powershell script?? So i've got this nifty PowerShell script that needs to be scheduled to run every day. I'm sure this is an incredibly easy question (forgive me, i'm a "newbie"), but how the heck do i schedule it as an AT job? I can schedule standard .BAT files no problem, but how do i tell the job to run in a PowerShell envioronment? Does PowerShell have its own internal scheduling mechanism? If it matters, this is actually for the Exchange 2007 PowerShell. Thanks in advance! jim |
My System Specs![]() |
| | #2 (permalink) |
| | RE: How to schedule a Powershell script?? "jim" wrote: > I can schedule standard .BAT files no problem, but how do i tell the job to run in a > PowerShell envioronment? The easiest way is probably to put something like the following in your batch file: powershell.exe -command C:\do-foo.ps1 <script_parameter1> <script_parameter2> Try "powershell -?" so see more command line options. > Does PowerShell have its own internal scheduling > mechanism? Not yet, but afaik it is planned for one of the next major versions. -- greetings dreeschkind |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How to schedule a Powershell script?? I keep getting "powershell is not a valid command". Maybe it's the version of Exchange i'm running. In any event, i figured out "A" way to do it (probably not the most graceful, but it works for me). "C:\Program Files\Microsoft Command Shell\v1.0\Msh.exe" -mshconsolefile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.mcf1" -command "& 'get-UserAttributes.msh' " "dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message news:F4B69041-22F2-4A7F-8F1B-B0A56D721FDC@microsoft.com... > "jim" wrote: > >> I can schedule standard .BAT files no problem, but how do i tell the job >> to run in a >> PowerShell envioronment? > > The easiest way is probably to put something like the following in your > batch file: > powershell.exe -command C:\do-foo.ps1 <script_parameter1> > <script_parameter2> > > Try "powershell -?" so see more command line options. > >> Does PowerShell have its own internal scheduling >> mechanism? > > Not yet, but afaik it is planned for one of the next major versions. > > -- > greetings > dreeschkind |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How to schedule a Powershell script?? "jim" wrote: > I keep getting "powershell is not a valid command". Maybe it's the version > of Exchange i'm running. In any event, i figured out "A" way to do it > (probably not the most graceful, but it works for me). Sorry, I missed the fact that you are using the Exchange shell. This one is based on an older PowerShell release (it was called msh before). As you figured out, you need to pass the (*.msh instead of *.ps1) script to the script engine (in your case msh.exe instead of powershell.exe). However, I expect the script engine of next release of the Exchange shell to be called powershell.exe as well. -- greetings dreeschkind |
My System Specs![]() |
| | #5 (permalink) |
| | Re: How to schedule a Powershell script?? I've heard that too. "dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message news:EE15BB93-EA46-4ECC-AB04-058549C838C7@microsoft.com... > "jim" wrote: > >> I keep getting "powershell is not a valid command". Maybe it's the >> version >> of Exchange i'm running. In any event, i figured out "A" way to do it >> (probably not the most graceful, but it works for me). > > Sorry, I missed the fact that you are using the Exchange shell. This one > is > based on an older PowerShell release (it was called msh before). As you > figured out, you need to pass the (*.msh instead of *.ps1) script to the > script engine (in your case msh.exe instead of powershell.exe). However, I > expect the script engine of next release of the Exchange shell to be > called > powershell.exe as well. > > -- > greetings > dreeschkind |
My System Specs![]() |
| | #6 (permalink) |
| | Re: How to schedule a Powershell script?? assuming exchange powershell engine upgraded nex time, to run command script locally at the exchange server, ie powershell -command <*.ps1> ...make sure u do set-executionpolicy correctly , otherwise it won't run at command prompt. "jim" <jim@nospam.com> wrote in message news:uKArzV58GHA.1492@TK2MSFTNGP02.phx.gbl... > I've heard that too. > > "dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message > news:EE15BB93-EA46-4ECC-AB04-058549C838C7@microsoft.com... >> "jim" wrote: >> >>> I keep getting "powershell is not a valid command". Maybe it's the >>> version >>> of Exchange i'm running. In any event, i figured out "A" way to do it >>> (probably not the most graceful, but it works for me). >> >> Sorry, I missed the fact that you are using the Exchange shell. This one >> is >> based on an older PowerShell release (it was called msh before). As you >> figured out, you need to pass the (*.msh instead of *.ps1) script to the >> script engine (in your case msh.exe instead of powershell.exe). However, >> I >> expect the script engine of next release of the Exchange shell to be >> called >> powershell.exe as well. >> >> -- >> greetings >> dreeschkind > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Schedule PowerShell script with Windows Server 2003 | PowerShell | |||
| how to schedule a job or run a script with elevated privleges? | VB Script | |||
| when run powershell script as windows service ,powershell fail | PowerShell | |||
| How to schedule a Power Shell script | PowerShell | |||
| schedule task in powershell | PowerShell | |||