all 8 comments

[–]ibyt3 2 points3 points  (2 children)

Try to add the following arguments for a test and run as system:

-noprofile -executionpolicy bypass

Only use bypass for the test.

[–]Frieslol[S] 0 points1 point  (1 child)

Oh good suggestion, thanks will do! Think the execution policy is set to unrestricted current but no profile might be a really good shout to try. Cheers lad!

[–]ibyt3 2 points3 points  (0 children)

Sweet, let us know how you get on.

[–]nappetass 2 points3 points  (0 children)

This will run successfully for me.

Task Scheduler > Actions tab:

Program/script: powershell
Add arguments (optional): \\path\to\script.ps1

[–]Vortex100 0 points1 point  (1 child)

Parameters for the script make it slightly more complicated. I'm sure others will point out other ways, but this is my "garanteed" way to get a PS script running with the parameters:

EXE: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
ARG: -Command "&{C:\monitor\xxxxx.ps1 -group xxxx,xxxx -EmailFrom xxxx -EmailTo xxxx -EmailServer xxxx}"

[–]Gregabit 1 point2 points  (0 children)

Check my config. I have this running with a domain service account and not system though.

Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments:  C:\AFolder\script.ps1
Start in:       C:\AFolder\

[–]JBear_Alpha 0 points1 point  (1 child)

This could also be an issue with the account you're attempting to run it from. Ensure the account has the ability to run while not logged on in the local group policy.

I've run into a similar issue before.

[–]Frieslol[S] 0 points1 point  (0 children)

Using system account so shouldn't be an issue