我已经在其他问题中查看了有关任务调度程序答案的所有PowerShell脚本,但未能找到解决此问题的脚本。
我尝试使用以下方法直接通过任务计划程序运行PowerShell脚本:
powershell.exe -file c:\path_to_your_script\script.ps1
创建批处理以运行PowerShell脚本。
PowerShell脚本可以完美地找到它自己运行以及手动运行批处理时。
打开excel,刷新,保存和关闭。
我无法通过任务处理程序成功安排此操作。
有什么建议吗?
感谢您的帮助
编辑:
@luke这是导出任务调度程序的设置
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2015-05-11T12:40:51.6084684</Date>
<Author>----------</Author>
</RegistrationInfo>
<Triggers>
<TimeTrigger>
<Repetition>
<Interval>PT1H</Interval>
<StopAtDurationEnd>false</StopAtDurationEnd>
</Repetition>
<StartBoundary>2015-05-11T12:30:00</StartBoundary>
<Enabled>true</Enabled>
</TimeTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>------\Administrator</UserId>
<LogonType>Password</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>true</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>true</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\Windows\System32\cmd.exe</Command>
<Arguments>/q /c "C:\Users\---------\Documents\PowerBI\PowerShell\RunExcelRefreshingScriptPowerShell2.bat"</Arguments>
</Exec>
</Actions>
</Task>
答案 0 :(得分:1)
是否可以在没有用户名或密码的情况下提供任务时间表设置的导出。
我有很多通过任务计划程序运行的功能,而不是一个问题,因为我的调度程序调用了启动powershell的bat。
这是您可以找到最后一次运行结果的地方。
答案 1 :(得分:1)
我遇到了同样的问题,我创建了一个计划任务来运行我创建的PowerShell脚本。我发现如果你在程序/脚本窗口中添加Powershell.exe的路径(即:%SystemRoot%\ system32 \ WindowsPowerShell \ v1.0 \ powershell.exe)以及实际PowerShell脚本的路径(即:D) :\ Scripts \ PowershellScript.ps1)(参见下面的示例)它将在Arguments窗口中工作。您还必须检查服务器的PowerShell执行策略,以确保它设置为“不受限制的”#34;。您也可以尝试将其添加为参数(-ExecutionPolicy Bypass)。 我希望这会对某人有所帮助。 例: Task to Run PowerShell Scripts