Solved

RedistributeActiveDatabases.ps1 not running via Task Scheduler

Posted on 2013-11-27
9
2,567 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
In this video we show how to create a Distribution Group 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 >>…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

777 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