Solved

RedistributeActiveDatabases.ps1 not running via Task Scheduler

Posted on 2013-11-27
9
2,687 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 1

Author Comment

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

Accepted Solution

by:
Subsun earned 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Check out this step-by-step guide for using the newly updated Experts Exchange mobile app—released on May 30.
In this video we show how to create a Contact 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 Recipients >> Contact ta…
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…

728 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