troubleshooting Question

Cannot Run Disable-ADAccount as Scheduled Task on Server

Avatar of Diane Burns
Diane BurnsFlag for United Kingdom of Great Britain and Northern Ireland asked on
Powershell* task scheduler
3 Comments1 Solution91 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
Chris Dent
PowerShell Developer
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros