有没有办法在Windows Server 2008和2003中的任务调度程序中了解任务的来源和合法性? 我可以检查任务是否由微软(即:从sccm)或第三方应用程序添加?
对于任务调度程序中的每个任务,我想validation该任务尚未由第三方应用程序创build。 我只想让标准的Microsoft Tasks和禁用所有其他非标准任务。
我创build了一个PowerShell脚本,通过C:\ Windows \ System32 \ Tasks目录中的所有xml文件,并且能够成功读取所有的xml任务文件,但是我被困在如何validation任务。
以下是供您参考的脚本:
Function TaskSniper() { #Getting all the fils in the Tasks folder $files = Get-ChildItem "C:\Windows\System32\Tasks" -Recurse | Where-Object {!$_.PSIsContainer}; [Xml] $StandardXmlFile = Get-Content "Edit Me"; foreach($file in $files) { #constructing the file path $path = $file.DirectoryName + "\" + $file.Name #reading the file as an XML doc [Xml] $xmlFile = Get-Content $path #DS SEE: http://social.technet.microsoft.com/Forums/en-US/w7itprogeneral/thread/caa8422f-6397-4510-ba6e-e28f2d2ee0d2/ #(get-authenticodesignature C:\Windows\System32\appidpolicyconverter.exe).status -eq "valid" #Display something $xmlFile.Task.Settings.Hidden } }
合法性听起来含糊不清。
如果来源是指“作者”,则可在“主体”节点中find:
$xmlFile.Task.Principals.ChildNodes id GroupId RunLevel -- ------- -------- Author S-1-5-32-545 LeastPrivilege
另一种方法可能是审计何时和谁创build计划任务。 Hera是Windows 2008 R2的安全事件ID:
4698 A scheduled task was created. 4700 A scheduled task was enabled. 4702 A scheduled task was updated.