我正在运行AWS ec2
个Windows服务器。我有powershell script
运行来安排任务每小时运行一个生成报告的程序,并将其收集在一个文件夹中。通过单击调度程序手动运行此任务时,输出正常。但是,当我运行我的脚本来运行它时,一切似乎都运行良好,但报告没有收集在文件夹中。我已经尝试了几种调度程序选项的变体,但它与手动运行一起工作的事实让我觉得这不是问题。我也在运行ansible
脚本中的powerhsell脚本。
scheduletask.ps1:
`$ErrorActionPreference = "SilentlyContinue"
schtasks /query /tn "RunNetSparker"""
if ($?)
{
SCHTASKS /DELETE /TN "RunNetSparker" /F
}
schtasks /create /RU Administrator /RP "{{ win_initial_password }}" /tn RunNetSparker /xml "C:\Users\Administrator\Documents\Netsparker_Files\scheduleschema.xml" /f`
这是配置xml:
`<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2018-05-04T13:51:42</Date>
<Author>Administrator</Author>
</RegistrationInfo>
<Triggers>
<TimeTrigger>
<Repetition>
<Interval>PT10M</Interval>
<StopAtDurationEnd>false</StopAtDurationEnd>
</Repetition>
<StartBoundary>2018-05-04T15:30:00</StartBoundary>
<Enabled>true</Enabled>
</TimeTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-18</UserId>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>
<WakeToRun>true</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\Users\Administrator\Documents\Netsparker_Files\NetScanConfig.bat</Command>
</Exec>
</Actions>
</Task>`