How to Run the PowerShell Script in Scheduled Task with Run as Administrator

By | August 30, 2018

PowerShell Script not working through Task Scheduler: how to execute powershell script to run as administrator in a scheduled task? some powershell scripts are failed to run on scheduled task and it won’t through any error on task history (even on the task scheduler events didn’t getting any errors) just didn’t get the output what we expect (this is happening on Windows server 2012 R2 and 2016), however same script able to run without any issue directly, done extensive debugging on the powershell script and found error related to activex, how to fix this

Also Read: Powershell command to the Get Account expiration date, Extract user list which expire in a week time

It works, If you run a powershell script with run as administrator and needs to do the same on task scheduler to fix the issue, how to do this?

How can I execute the Scheduled task to run as Administrator?

  • Open scheduled task
  • Click properties of task
  • Go to Actions and select New and set the action to Start a program.
  • Update below
  • Program/scripts: PowerShell.exe
  • Add arguments (optional): -ExecutionPolicy Bypass -File <Ps1 Script Location>
  • Click OK

Also Read: PowerShell command to extract Group policy result for a list of Servers

Through this way we can run the PS1 script run as an Administrator on schedule task, if  PowerShell script only be work when execute it via Run as Administrator

Also Read: Enable Powershell Remoting on Windows server 2008 R2 and 2012

Run with highest privileges task scheduler

Also try configuring task scheduler with run with highest privileges

  • Open scheduled task
  • Click properties of task
  • In General tap
  • Select Run with highest privileges
  • Click OK

Also Read: Active Directory 2016 New Features


Leave a Reply

Your email address will not be published. Required fields are marked *