Powershell 任务计划程序任务未执行ps1脚本

Powershell 任务计划程序任务未执行ps1脚本,powershell,task,taskscheduler,Powershell,Task,Taskscheduler,我正在尝试在任务计划程序中运行ps1文件。 任务应该每天晚上运行,历史表明它已经运行 但这并不是真的,因为我可以从SonarQube身上看出它没有 每一步都按预期进行,如果我运行操作并发出命令,一切正常: powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\sonarqube\run_sonar_scan.ps1 我还尝试使用powershell的完整路径 任务: <?xml version="1.

我正在尝试在任务计划程序中运行ps1文件。 任务应该每天晚上运行,历史表明它已经运行

但这并不是真的,因为我可以从SonarQube身上看出它没有

每一步都按预期进行,如果我运行操作并发出命令,一切正常:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\sonarqube\run_sonar_scan.ps1
我还尝试使用powershell的完整路径

任务:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2020-07-27T13:10:30.3806911</Date>
    <Author>xxx\yyy</Author>
    <Description>Starts the SonarScanner bat files from run_sonar_scan.ps1</Description>
    <URI>\DdDRetail\SonarScanner</URI>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2020-07-27T21:00:00</StartBoundary>
      <ExecutionTimeLimit>PT4H</ExecutionTimeLimit>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-18</UserId>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>false</AllowHardTerminate>
    <StartWhenAvailable>true</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>true</UseUnifiedSchedulingEngine>
    <WakeToRun>true</WakeToRun>
    <ExecutionTimeLimit>PT8H</ExecutionTimeLimit>
    <Priority>7</Priority>
    <RestartOnFailure>
      <Interval>PT1M</Interval>
      <Count>3</Count>
    </RestartOnFailure>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>powershell.exe</Command>
      <Arguments>-NoProfile -ExecutionPolicy Bypass -File "C:\sonarqube\run_sonar_scan.ps1"</Arguments>
    </Exec>
  </Actions>
</Task>
蝙蝠档案

  • 从github更新本地回购协议
  • 更新Nuget软件包
  • 运行声纳扫描仪

无论用户是否登录,用户都需要是管理员或具有运行权限。用户已更改为管理员,一切正常,任务按预期执行。

我发现使用“无论用户是否登录都运行”阻止了执行。取消选中时,任务运行正常。-现在转到IT部门,获取我的用户所需的权限。请查看并在两天后返回,如果您的声誉超过15,请按回答进行检查。
$repo_file_path="C:\Users\xxx\source\repos"

Start-Process "cmd.exe"  "/c $repo_file_path\run_articleservice_scan.bat"