Powershell exchange: how do you set up a scheduled task to run an exchange2007 powershell?
I am having trouble setting up a scheduled task (now called Task Scheduler) under the actions tab to run on a Windows 2007 server. It also has Exchange Server 2007.
I 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 ( optional): "C: \ Program Files \ Microsoft \ Exchange Server \ Bin \
I understand that exshell.psc1 probably needs an explicit path as well, so I also tried:
-psconsolefile C: \ Program Files \ Microsoft \ Exchange Server \ Bin \ exshell.psc1 -command "& {c: \ mes-detail \ mailall3.ps1}" but that doesn't work either
Any ideas?
source to share
I decided that I would agree with this decision in order to finish what I started.
1) In the .ps1 file add Add-PSSnapin exchange
2) for scheduled task, do the following: Program / script: C: \ Windows \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe Add arguments (optional): -noprofile -Non-interactive c: \ mes-detail \ emsbilling08.ps1 Home in (optional): "C: \ Program Files \ Microsoft \ Exchange Server \ Bin \
If it still doesn't work, do the following checks:
Start ... Run C: \ Windows \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe -noprofile
Get-PSSnapin -Registered
You see Microsoft.Exchange.Management.PowerShell.Admin Microsoft.Exchange.Management.Powershell.Support
If so, replace the add-pssnapin command
source to share
What does not work? Have you tried running one of these commands manually to see what's going on?
(BTW: Suggestion, you might want to take this to the PowerShell forum at minasi.com/forum or powershelcommunity.org. You will probably ask a wider audience that is well versed in this topic, as this is sort of a borderline for StackOverflow oriented per programmer).
source to share
PS C: \ Windows \ System32 \ WindowsPowerShell \ v1.0> add-pssnapin exchange Add-PSSnapin: Windows PowerShell binding to computer is not installed and not installed. On line: 1 char: 13 + add-pssnapin <exchange
Enter the full name in your script:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Support
source to share