osagarana
asked on
Getting frustrated to run an Exchange script via Task Scheduler
Hi Experts,
I am getting really frustrated to run two PowerShell Exchange scripts via Task Scheduler.
They are:
Get-ExchangeEnvironmentRep ort >> http://www.stevieg.org/2011/06/exchange-environment-report/
Test-ExchangeServerHealth >> http://exchangeserverpro.com/health-check-exchange-2010-mailbox-server/
Environment:
Windows 2008 R2
Exchange 2010
Problem >>
I have two environments:
Lab Environment: Both work via Task Scheduler and when I run manually.
Production Environment: Only if I run the scripts manually. Not via Task Scheduler.
The user I am using on my production environment is a member of Domain Admins + Organization Management.
If I log in the production environment I can run my scripts manually successfully.
========================== ========== ========
How my Task is configured:
Run whether user is logged or not - checked
Run with high privileges - checked
Program/script: C:\Windows\System32\Window sPowerShel l\v1.0\pow ershell.ex e
Argument: -c "push c:\scripts; c:\scripts\Get-ExchangeEnv ironmentRe port.ps1 -HTMLReport c:\scripts\report.html -SendMail:$true -MailFrom:me@domain.com -Mailto:me@domain.com -MailServer:smtp.domain.co m
No matter what I do, the task seems to complete(according the history of the task - no erros whatsoever) but it does not send the report.
========================== ========== ========
Initially I thought was my SMTP server, but if I run the script manually works....like:
.\Get-ExchangeEnvironmentR eport.ps1 -HTMLReport c:\scripts\report.html -SendMail:$true -MailFrom:me@domain.com -Mailto:me@domain.com -MailServer:smtp.domain.co m
I already ran:
Set-ExecutionPolicy Unrestricted
Set-ExecutionPolicy RemoteSigned
No difference!
-------------------------- ---------- ---------
It is not a problem with the script. If I run manually it works. The same happens with the other script (Test-ExchangeServerHealth ). If I run mannually it works. If I try to run via Task Scheduler, nothing happens.
I reckon it is a permission issue. But to be honest I am running out of ideas.
Any ideas?
I am getting really frustrated to run two PowerShell Exchange scripts via Task Scheduler.
They are:
Get-ExchangeEnvironmentRep
Test-ExchangeServerHealth >> http://exchangeserverpro.com/health-check-exchange-2010-mailbox-server/
Environment:
Windows 2008 R2
Exchange 2010
Problem >>
I have two environments:
Lab Environment: Both work via Task Scheduler and when I run manually.
Production Environment: Only if I run the scripts manually. Not via Task Scheduler.
The user I am using on my production environment is a member of Domain Admins + Organization Management.
If I log in the production environment I can run my scripts manually successfully.
==========================
How my Task is configured:
Run whether user is logged or not - checked
Run with high privileges - checked
Program/script: C:\Windows\System32\Window
Argument: -c "push c:\scripts; c:\scripts\Get-ExchangeEnv
No matter what I do, the task seems to complete(according the history of the task - no erros whatsoever) but it does not send the report.
==========================
Initially I thought was my SMTP server, but if I run the script manually works....like:
.\Get-ExchangeEnvironmentR
I already ran:
Set-ExecutionPolicy Unrestricted
Set-ExecutionPolicy RemoteSigned
No difference!
--------------------------
It is not a problem with the script. If I run manually it works. The same happens with the other script (Test-ExchangeServerHealth
I reckon it is a permission issue. But to be honest I am running out of ideas.
Any ideas?
Is the task configured to run with the credentials of the correct mailbox owner (i.e. the me@domain.com in your example)?
ASKER
Sorry. I did not understand your question LeeDerbyshire.
Is user account control disabled in your test environment? There must be some differences.
As far as I can remember, when you create a Task, it asks you to provide a username and password when you finally click the OK button (or maybe it's just an option within one of the Task configuration pages now). If it did ask, or if you see the option anywhere within the Task configuration pages, did you supply the account name and password of the owner of the mailbox you are trying to send the email from?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for osagarana's comment #a39626109
for the following reason:
I found the solution myself.
Accepted answer: 0 points for osagarana's comment #a39626109
for the following reason:
I found the solution myself.
in that case you should get your points back...