积极答复者
windows2012R2 计划任务如何运行powershell 脚本

问题
答案
-
您好 siqiwang,
您可以参考以下的文章:
如何从批处理文件运行PowerShell脚本
https://gxnotes.com/article/39295.html
http://blog.danskingdom.com/allow-others-to-run-your-powershell-scripts-from-a-batch-file-they-will-love-you-for-it/
请注意:非微软官方网站发布,不能保证信息的可靠性。
此致
Candy
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.- 已标记为答案 siqiwang 2017年7月21日 1:33
全部回复
-
您好 siqiwang,
>>windows2012R2 计划任务如何运行powershell 脚本
$Taskname = 'RunPSScriptAt9' $user = "candy\administrator" $scriptpath = "\\powershellscript\test.ps1" $trigger = New-ScheduledTaskTrigger -At 9:00am -Daily $Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-executionpolicy bypass -noprofile -file $scriptpath" Register-ScheduledTask -TaskName $Taskname -Trigger $trigger -User $user -Action $Action -RunLevel Highest -Force
您可以尝试以上的脚本来新建计划任务来测试是否可以自动周期运行。
此致
Candy
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com. -
您好 siqiwang,
根据我们之前测试的经验,发现直接在在计划任务中运行power shell的脚本总是会出现问题。可能是由于某种格式限制问题。
曾经有方式是用.bat脚本调用powershell脚本,从而实现计划任务执行powershell脚本。您可以进行尝试。此致
Candy
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com. -
您好 siqiwang,
您可以参考以下的文章:
如何从批处理文件运行PowerShell脚本
https://gxnotes.com/article/39295.html
http://blog.danskingdom.com/allow-others-to-run-your-powershell-scripts-from-a-batch-file-they-will-love-you-for-it/
请注意:非微软官方网站发布,不能保证信息的可靠性。
此致
Candy
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.- 已标记为答案 siqiwang 2017年7月21日 1:33