0

I have a windows 10 task that Im trying to set to run as a domain user that is also in the local admin group on the machine im running it. The action is running a powershell script. I know the script works fine as when I run the task under my account, it works fine. When running it as the domain account it seems to do nothing. Where can I check for error messages? One action I set before calling the script is also using powershell and sets the execution policy to unrestricted. Shouldnt being in the local admin group be sufficient permissions for this?

Here is the powershell script

Echo "test"
Read-Host -Prompt "press any key to exit"
  • How can you expect an answer if you don't show us this script? – DavidPostill Feb 16 '17 at 14:33
  • Have you checked the option "Run this task with administrative privileges"? – InterLinked Feb 18 '17 at 14:44
0

There are 3 actions (1) Powershell: command =

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

(2) Powershell: run a script that has

Echo "test"
Read-Host -Prompt "press any key to exit"

(3) Set-ExecutionPolicy -ExecutionPolicy Restricted

What I was missing was on the 1st step

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force
  • The problem with setting the -ExecutionPolicy Unrestricted is that it changes the overall security level for script execution so you also should set it back to restricted once you run the script or else the overall security stays unrestricted. Unlike in my answer where you use the -ExecutionPolicy Bypass it just bypasses the execution policy restriction for only that run/session of script execution without affecting the overall security of the execution policy so no need to revert back afterwards and no need to compromise security defaults. – Pimp Juice IT Mar 9 '17 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.