PowerShellPack - TaskScheduler 模块 - 在没有登录用户的情况下运行任务 [英] PowerShellPack - TaskScheduler module - run task with no logged user

查看:59
本文介绍了PowerShellPack - TaskScheduler 模块 - 在没有登录用户的情况下运行任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 Windows Server 2008 上通过 Powershell v2 安排任务.我正在使用 MS PowershellPack.

I need to schedule a task via Powershell v2 on Windows Server 2008. I am using the TaskScheduler module from the MS PowershellPack.

安排任务没问题,但我需要即使没有人登录也能运行任务.我看到这在 Win8 或 Win2k12 上的 Powershell v3 中是可能的(此质量检查).但这不是我的情况 - 我需要在 Powershell 版本 2 中这样做.

Scheduling a task is ok, but I need the task to run even nobody is logged on. I saw that this is possible in Powershell v3 on Win8 or Win2k12 (this QA). But that is not my case - I need to this in Powershell version 2.

这可能与我正在使用的模块有关吗?或者有什么解决方法?

Is this possible with module I am using? Or is there some workaround?

推荐答案

http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357(v=vs.85).aspx

在 V2 世界里是不可能的,但这会完成你需要的一切,并且可以直接从 powershell 调用

Not possible down in the V2 world, But this will accomplish everything you need, and can be directly called from powershell

这个问题让我思考,我意识到你的情况与我的略有不同,所以这应该可能......所以我以前错了.事实证明,Scheduler.service comobject 与 Powershell 2.0 兼容,但也仅适用于 Task Scheduler 2.0.我以为不是因为我使用的是 xp,而 Task Scheduler 2.0 仅在 vista 及更高版本中可用.

This question got me thinking, and I realized your scenario is slightly different than mine, making it so this Should Be Possible.. So I was wrong before. Turns out, the Scheduler.service comobject is compatible with Powershell 2.0, but also only works with Task Scheduler 2.0. I thought it wasn't because I am on xp, and Task Scheduler 2.0 is only available in vista and up.

查看那个 MS PowershellPack 的源代码,我发现它所做的只是使用 Scheduler.service com 对象.https://github.com/sushihangover/SushiHangover-PowerShell/tree/主/模块/TaskScheduler

Looking into the source code of that MS PowershellPack, I found that all it is doing is using the Scheduler.service com object. https://github.com/sushihangover/SushiHangover-PowerShell/tree/master/modules/TaskScheduler

关于如何自己操作这个 com 对象的好教程:https://blogs.technet.microsoft.com/heyscriptingguy/2009/04/01/hey-scripting-guy-how-can-i-best-work-with-task-scheduler/

For a good tutorial of how to manipulate this com object for yourself : https://blogs.technet.microsoft.com/heyscriptingguy/2009/04/01/hey-scripting-guy-how-can-i-best-work-with-task-scheduler/

以及您问题的答案:如何设置 schedule.service "无论用户是否登录都运行";在 Powershell 中?

对不起,误会了..我不会让它再次发生:D
无论哪种方式,schtasks.exe 都将涵盖您的所有基础,并且 IMO 更易于使用,因为它是一个命令,并且在尝试在远程服务器上安排任务时不需要您调用会话.

Sorry for the misunderstanding.. I won't let it happen again :D
Either way the schtasks.exe will cover all your bases and IMO is easier to work with, because it is one command, and doesnt require you to Invoke-Session when trying to schedule a task on a remote server.

这篇关于PowerShellPack - TaskScheduler 模块 - 在没有登录用户的情况下运行任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆