Another Task Scheduler not executing PowerShell

I have a simple PowerShell script that just creates a file. Testing this for a bigger PowerShell script.

Running on Windows Server 2012 R2 - 64-bit

its running under the Administrator account.

Run whether user is logged on or not

Run with highest privileges


Action: Program/Script : Powershell.exe (I've tried it this way and the full path)

Add argumetns: -NoProfile -executionpolicy remotesigned -file C:Scriptstest.ps1


Get-executionPolicy: RemoteSigned

added "Administrator" to: Set-PSSSessionConfiguration -Name Microsoft.PowerShell -ShowSecurityDescriptorUI

"Administrator" has "Log on as batch job" permissions "Administrator" is in the Admins group

PowerShell Script for testing:

    $text = "Hello World"

    $text | Set-Content TestMyFile.txt
    $text | Out-File TestMyFile.txt
    $text > TestMyFile.txt

    # This is to write into a file or append to the text file created:
    $text | Add-Content TestMyFile.txt
    $text | Out-File TestMyFile.txt -Append
    $text >> TestMyFile.txt

Nothing fancy, just trying to make sure Task Scheduler will execute a PowerShell script.

So What am I missing?


Use full paths in your output code, and for any future problems with running scripts from Task Scheduler, you should first put in logging and try/catch blocks to see what errors/outputs the script is generating before seeking further assistance. Doing this will help you find the answer faster & learn faster at the same time.

Tip: Always only name the program in the 'Program to run' aspect of Task Scheduler, as the Task Scheduler uses its own wrapper to execute the action, and in rare occasions, it can produce undesired results if you place the entire execution line in this field. Always put parameters in the parameters field.

链接地址: http://www.djcxy.com/p/61086.html

上一篇: 使用Hibernate Validator进行交叉字段验证(JSR 303)

下一篇: 另一个任务计划程序不执行PowerShell