Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Getting frustrated to run an Exchange script via Task Scheduler

Posted on 2013-11-01
8
Medium Priority
?
1,199 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
Q2 2017 - Latest Malware & Internet Attacks

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out our latest Quarterly Internet Security Report!

 
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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…
This video discusses moving either the default database or any database to a new volume.

618 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