首先创建普通计划任务,定好执行时间,千万千万记得设置任务的起始路径.
然后导出xml到指定目录,执行如下脚本批量注册/取消windows cluster task:
function ImportTasks( [String]$xmlPath,[String]$clusterName)
{ #[String]$root,#taskpath is not support in cluster task $files = Get-ChildItem $xmlPath foreach($f in $files) { #if xml $name = $f.Name.Substring(0,$f.Name.Length-4) $fullName = $xmlPath + "\" + $f.Name $userfile = Get-Content $fullName | Out-String Register-ClusteredScheduledTask –Cluster $clusterName –TaskName $name –TaskType AnyNode -Xml $userfile # Unregister-ClusteredScheduledTask –Cluster devCluster –TaskName $name } } ImportTasks "C:\Work\TaskJobs\Surveryapp" "devCluster"