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

x
?
Solved

RedistributeActiveDatabases.ps1 not running via Task Scheduler

Posted on 2013-11-27
9
Medium Priority
?
2,826 Views
Last Modified: 2013-11-28
Hi Experts,

Environment: Exchange 2010 SP2 + Windows 2008 R2

I am having some issues to run a built-in Exchange Script using Task Scheduler.
I have no issues running the script manually like:
.\RedistributeActiveDatabases.ps1 -DagName DAG01 -BalanceDbsByActivationPreference -confirm:$false

My task scheduler shows as completed successfully (0x0). But nothing happens.

I already changed the quotes several times but so far no luck.

Here it is how the task is set:
Run whether user is logged on or not - checked
Run with highest privileges - checked

Program/script: poweshell.exe
Add arguments: -command ". 'c:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; 'c:\Program Files\Microsoft\Exchange Server\V14\Scripts\RedistributeActiveDatabases.ps1 -DagName DAG01 -BalanceDbsByActivationPreference -confirm:$false'"


Does anyone has any idea why the script is not running via Task?  
It runs fine manually.
The user has the highest permission(Administrator).

Regards
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
  • 5
  • 3
9 Comments
 
LVL 8

Expert Comment

by:J S
ID: 39682398
Does the user have Exchange permissions? Running powershell commands will require the user (domain account) to be assigned the Exchange role access necessary to perform the action.
0
 
LVL 1

Author Comment

by:osagarana
ID: 39682425
Hi Jason,

The user "Administrator" has Domain Admins, Enterprise Admins, Schema Admins and Organization Management.
0
 
LVL 1

Author Comment

by:osagarana
ID: 39682426
ahhh...and the "Administrator" is local adminstrator as well.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 1

Author Comment

by:osagarana
ID: 39684410
no idea guys?
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39684483
Syntax to run the script is wrong..You have entered the entire code inside a  single quotation. So PowerShell consider it as a string..
.....ps1'; Connect-ExchangeServer -auto; 'c:\Program Files\Microsoft\Exchange Server\V14\Scripts\RedistributeActiveDatabases.ps1 -DagName DAG01 -BalanceDbsByActivationPreference -confirm:$false'"

Open in new window

Try the following code and see if it works..
-command ". 'c:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto;. 'c:\Program Files\Microsoft\Exchange Server\V14\Scripts\RedistributeActiveDatabases.ps1' -DagName DAG01 -BalanceDbsByActivationPreference -confirm:$false"

Open in new window

0
 
LVL 1

Author Comment

by:osagarana
ID: 39684519
Hi Subsun,

Unfortunately it did not work.
The history of the Task Scheduler says Action completed with return code 0. It means kind of completed successfully 0x0

However the script did not run. I mean, the "RedistributeActiveDatabases.ps1" did not do the job.

If I run this thing manually it works from Powershell:
c:\Program Files\Microsoft\Exchange Server\V14\Scripts
.\RedistributeActiveDatabases.ps1 -DagName DAG01 -BalanceDbsByActivationPreference -confirm:$false


I am changing the quotes everywhere. Some give 0x0(good) and some give 0x1(wrong). But none of them have ran the script properly.

This script is built-in for Exchange 2010(DAG rebalancing). It should not be difficult to run.  :-(
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39684521
What if you run the following from command prompt..
Powershell -command ". 'c:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto;. 'c:\Program Files\Microsoft\Exchange Server\V14\Scripts\RedistributeActiveDatabases.ps1' -DagName DAG01 -BalanceDbsByActivationPreference -confirm:$false"

Open in new window

1
 
LVL 1

Author Closing Comment

by:osagarana
ID: 39684530
Sorry. You are definately a genius. It worked you said.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39684532
Nice!
0

Featured Post

WEBINAR - Latest Cyber Tips for Defense

Join the WatchGuard Threat Research Team on October 26th for an informative webinar featuring expert tips and tricks for defending your organization from today's latest cyber threats. Don't leave yourself vulnerable to attack. Register for the webinar today!

Question has a verified solution.

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

Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
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

610 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