Solved

RedistributeActiveDatabases.ps1 not running via Task Scheduler

Posted on 2013-11-27
9
2,491 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
  • 5
  • 3
9 Comments
 
LVL 6

Expert Comment

by:jasons73
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
 
LVL 1

Author Comment

by:osagarana
ID: 39684410
no idea guys?
0
Why spend so long doing email signature updates?

Do you spend loads of your time carrying out email signature updates? Not very interesting are they? Don’t let signature updates get you down. Let Exclaimer Cloud - Signatures for Office 365 make managing email signatures a breeze.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
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 a mailbox database 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 Servers >> Data…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now