Link to home
Start Free TrialLog in
Avatar of osagarana
osagarana

asked on

RedistributeActiveDatabases.ps1 not running via Task Scheduler

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
Avatar of J S
J S
Flag of United States of America image

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.
Avatar of osagarana
osagarana

ASKER

Hi Jason,

The user "Administrator" has Domain Admins, Enterprise Admins, Schema Admins and Organization Management.
ahhh...and the "Administrator" is local adminstrator as well.
no idea guys?
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.  :-(
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

Sorry. You are definately a genius. It worked you said.
Nice!