使用powershell在windows 2008中调度任务 [英] scheduling task in windows 2008 with powershell
本文介绍了使用powershell在windows 2008中调度任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 Windows 2008 r2 中使用 powershell 安排任务.我用过
i want to schedule task in windows 2008 r2 with powershell. i used
$username = "BUILTIN\Users"
$TaskName = 'kakaka'
$t=1
$TaskRun = "$PSHome\powershell.exe Start-Process -FilePath 'C:\v.exe' -ArgumentList '/a' -Verb runas -WindowStyle Normal"
$start = (Get-Date).AddMinutes($t).ToString("HH:mm")
schtasks /create /ru $username /tn $Taskname /tr $TaskRun /sc once /st $start /f
在使用上述脚本时,我收到错误消息schtasks.exe:错误:任务 XML 包含一个格式不正确或超出范围的值."相同的脚本在 Windows 7 上运行良好.
on using above script i got an error "schtasks.exe : ERROR: The task XML contains a value which is incorrectly formatted or out of range." same script worked fine on windows 7.
推荐答案
似乎有密码问题,已在以下帖子中解决:
It seems there is issue of password which is resolved in below post :
SYMPTOMS
When you try to change the run as user for a scheduled task in Server 2008, The task is currently configured to runas SYSTEM. Using the following command line he receives the error.
c:\>SCHTASKS /CHANGE /TN TestTask /RU TestUser
SCHTASKS prompts the user for a password for the runas user account. After entering the password it displays the following error.
"ERROR: The task XML contains a value which is incorrectly formatted or out of range. (52,4):Task:"
The task's runas credentials have not changed.
RESOLUTION
To avoid this error you must add the /RP option with an "*". The new command line will look like this:
c:\>SCHTASKS /CHANGE /TN TestTask /RU TestUser /RP *
SCHTASKS prompts the user for a password for the runas user account. After entering the password the task is updated without error.
这篇关于使用powershell在windows 2008中调度任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文