We help IT Professionals succeed at work.

Cannot Run Disable-ADAccount as Scheduled Task on Server

Diane Burns
Diane Burns asked
on
85 Views
Last Modified: 2017-04-04
I am trying to setup a powershell script to run as a scheduled task that disables an AD account every evening.

Disable-ADAccount -Identity <UserName>

The above script works when run manually, but not as a scheduled task.  So far I have tried running this under the System account on both the DC (server 2008 R2) and another member server (server 2012 R2) but although they say "Task Completed" in the history, the account remains enabled.  To clarify, the settings are here GeneralActions
I have also tried running it as myself, but get the error that I need "Log on as batch right" permissions

So my question is what do I need to do to get this working?  And is it better to run it from the DC or the other server?

Thanks for your help
Comment
Watch Question

PowerShell Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Diane BurnsIT Support Analyst

Author

Commented:
Brilliant thank you that works!

For anyone reading this who needs to know the exact procedure, I used Delegation Wizard in AD to give the server account permissions to "create, delete and manage user accounts" on the OU containing the user account.

Thanks for pointing me in the right direction!
Diane BurnsIT Support Analyst

Author

Commented:
this method worked

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions