Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - How to schedule a Powershell script??

Reply
 
Old 10-19-2006   #1 (permalink)
jim


 
 

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 SpecsSystem Spec
Old 10-19-2006   #2 (permalink)
dreeschkind


 
 

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 SpecsSystem Spec
Old 10-19-2006   #3 (permalink)
jim


 
 

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 SpecsSystem Spec
Old 10-19-2006   #4 (permalink)
dreeschkind


 
 

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 SpecsSystem Spec
Old 10-19-2006   #5 (permalink)
jim


 
 

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 SpecsSystem Spec
Old 10-19-2006   #6 (permalink)
IT Staff


 
 

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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46