views:

1032

answers:

2

I'm having trouble setting up a scheduled task (now called Task Scheduler) under the actions tab to run on windows 2007 server. It also has exchange server 2007.

I've tried setting

Program/script : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Add arguments (optional): -psconsolefile exshell.psc1 -command "& {c:\mes-detail\emsbilling08.ps1}" Start in (optional): "C:\Program Files\Microsoft\Exchange Server\Bin\

I realize the exshell.psc1 probably also needs an explicit path so I've also tried:

-psconsolefile C:\Program Files\Microsoft\Exchange Server\Bin\exshell.psc1 -command "& {c:\mes-detail\mailall3.ps1}" as well but that doesn't work either

Any ideas?

A: 

What doesn't work? Have you tried running one of those commands manually, to see what happens?

(BTW: Suggestion, you may want to take this to the PowerShell forum at minasi.com/forum or powershelcommunity.org. You're likely to be asking a larger audience that's knowledgeable about the topic, since this is kinda borderline for StackOverflow's programmer-centric population).

Don Jones
cool.. thanks for pointing me in that direction
phill
A: 

I figured I'd share the resolution here to finish what is started.

1) In your .ps1 file put Add-PSSnapin exchange

2) for the scheduled task, do this: Program/script : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Add arguments (optional): -noprofile -Noninteractive c:\mes-detail\emsbilling08.ps1 Start in (optional): "C:\Program Files\Microsoft\Exchange Server\Bin\

If it still doesn't work, run the following checks:

Start...Run C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile

Get-PSSnapin -Registered

Do you see Microsoft.Exchange.Management.PowerShell.Admin Microsoft.Exchange.Management.Powershell.Support

If so, do add-pssnapin exchange

phill