Solved

Getting frustrated to run an Exchange script via Task Scheduler

Posted on 2013-11-01
8
1,103 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Find out what you should include to make the best professional email signature for your organization.
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

803 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