Solved

Getting frustrated to run an Exchange script via Task Scheduler

Posted on 2013-11-01
8
1,159 Views
Last Modified: 2013-11-07
Hi Experts,

I am getting really frustrated to run two PowerShell Exchange scripts via Task Scheduler.

They are:
Get-ExchangeEnvironmentReport  >> 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\WindowsPowerShell\v1.0\powershell.exe
Argument: -c "push c:\scripts; c:\scripts\Get-ExchangeEnvironmentReport.ps1 -HTMLReport c:\scripts\report.html -SendMail:$true -MailFrom:me@domain.com -Mailto:me@domain.com -MailServer:smtp.domain.com

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-ExchangeEnvironmentReport.ps1 -HTMLReport c:\scripts\report.html -SendMail:$true -MailFrom:me@domain.com -Mailto:me@domain.com -MailServer:smtp.domain.com


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?
0
Comment
Question by:osagarana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
8 Comments
 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 39616396
Is the task configured to run with the credentials of the correct mailbox owner (i.e. the me@domain.com in your example)?
0
 
LVL 1

Author Comment

by:osagarana
ID: 39618068
Sorry. I did not understand your question LeeDerbyshire.
0
 
LVL 12

Expert Comment

by:Dave
ID: 39618591
Is user account control disabled in your test environment? There must be some differences.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 39621120
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?
0
 
LVL 1

Accepted Solution

by:
osagarana earned 500 total points
ID: 39626109
Guys,

Thanks for your help. Believe or not I found my production Exchange is installed on D: and no C:
When I changed:
from: c:\scripts\Get-ExchangeEnvironmentReport.ps1
to: d:\scripts\Get-ExchangeEnvironmentReport.ps1
..everything started to work.

Best Regards and sorry for the inconvenience.
0
 
LVL 1

Author Comment

by:osagarana
ID: 39626110
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.
0
 
LVL 12

Expert Comment

by:Dave
ID: 39626654
in that case you should get your points back...
0

Featured Post

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
This video discusses moving either the default database or any database to a new volume.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question