I have a task setup:

  • Run whether logged in or not
  • Run with highest privs
  • When running the task use the following account (my admin account)

Program / Script: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe Arguments: -ExecutionPolicy Bypass C:\Temp\test.ps1

test.ps1 contains:

Write-Host "Hello"

If I run this script as my normal user without run as highest privs, powershell launches and it works as expected.

When using the above settings though, it shows as running, then shows as completed with a result of 0x0 but powershell doesn't launch.

Any ideas what I'm doing wrong?

Note: I've tried setting the Start In to C:\Temp, I've tried various other arguments like noprofile nologo etc.

  • it probably runs in a different user context, so it's not visible for you. try to create a txt file in your script to see if the script really runs or not. – SimonS Jul 6 '18 at 7:53
  • Good call. Will try. – webnoob Jul 6 '18 at 7:55
  • Right, it is running as the file is created. So that means the script is running - it's just not visible? That shouldn't be a problem as I can write a log file to show what it's doing instead. – webnoob Jul 6 '18 at 8:04
  • correct. I'm a little bit confused about "When running the task use the following account (my admin account)" - is that a different account than the one you're logged in with? – SimonS Jul 6 '18 at 8:05
  • Yes, on the domain I have a normal account for everyday usage and an admin one I use when I need to do an admin task (so we don't accidentally do something because we have admin rights by default on the account we always use) – webnoob Jul 6 '18 at 8:06

PowerShell is running in a different user-context since you run this task as a different user than you're currently logged in. That's why you don't see any PowerShell window.

To make sure that your script really runs, try creating a txt file in your script. if it gets created, your script runs.

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.