如何通过PowerShell cmdlet从Schtasks.exe获取所有可用信息?
当我在 Windows 服务器上使用 PowerShell Cmdlet Get-ScheduledTaskInfo
时,我得到以下数据
LastRunTime : 22/04/1932 11:30:30
LastTaskResult : 267011
NextRunTime :
NumberOfMissedRuns : 0
TaskName : \Microsoft\Windows\Workplace Join\Recovery-Check
TaskPath :
PSComputerName :
但是,当我使用 schtasks.exe 在同一台 Windows 服务器上查询同一计划任务时,我得到更多信息,如下所示。
HostName : ELT-W-PRD-AP-12
TaskName : \Microsoft\Windows\Workplace Join\Recovery-Check
Next Run Time : N/A
Status : Disabled
Logon Mode : Interactive/Background
Last Run Time : 30/11/1999 00:00:00
Last Result : 267011
Author : N/A
Task To Run : %SystemRoot%\System32\dsregcmd.exe /checkrecovery
Start In : N/A
Comment : Performs recovery check.
Scheduled Task State : Disabled
Idle Time : Disabled
Power Management :
Run As User : INTERACTIVE
Delete Task If Not Rescheduled : Disabled
Stop Task If Runs X Hours and X Mins : 02:00:00
Schedule : Scheduling data is not available in this format.
Schedule Type : At logon time
Start Time : N/A
Start Date : N/A
End Date : N/A
Days : N/A
Months : N/A
Repeat: Every : N/A
Repeat: Until: Time : N/A
Repeat: Until: Duration : N/A
Repeat: Stop If Still Running : N/A
如何使用 PowerShell Cmdlet 从计划任务中提取相同的信息,而不是依赖 schtasks.exe?
When I use the PowerShell Cmdlet Get-ScheduledTaskInfo
on a Windows server I get the following pieces of data
LastRunTime : 22/04/1932 11:30:30
LastTaskResult : 267011
NextRunTime :
NumberOfMissedRuns : 0
TaskName : \Microsoft\Windows\Workplace Join\Recovery-Check
TaskPath :
PSComputerName :
However, when I query the same scheduled task on the same Windows server using schtasks.exe I get far more information, as seen below.
HostName : ELT-W-PRD-AP-12
TaskName : \Microsoft\Windows\Workplace Join\Recovery-Check
Next Run Time : N/A
Status : Disabled
Logon Mode : Interactive/Background
Last Run Time : 30/11/1999 00:00:00
Last Result : 267011
Author : N/A
Task To Run : %SystemRoot%\System32\dsregcmd.exe /checkrecovery
Start In : N/A
Comment : Performs recovery check.
Scheduled Task State : Disabled
Idle Time : Disabled
Power Management :
Run As User : INTERACTIVE
Delete Task If Not Rescheduled : Disabled
Stop Task If Runs X Hours and X Mins : 02:00:00
Schedule : Scheduling data is not available in this format.
Schedule Type : At logon time
Start Time : N/A
Start Date : N/A
End Date : N/A
Days : N/A
Months : N/A
Repeat: Every : N/A
Repeat: Until: Time : N/A
Repeat: Until: Duration : N/A
Repeat: Stop If Still Running : N/A
How can I extract the same information from the scheduled task using PowerShell Cmdlets, rather than relying on schtasks.exe?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您使用Schtask搜索时,您使用 /详细的标志 - 您需要在此处执行此操作,然后说您要查看整个RETREERED属性列表。
编辑:只会提供:
When you search with schtasks you used the /Verbose flag - you need to do the same here, then also say you want to view the entire list of retreived properties.
edit: Get-ScheduledTaksInfo will only provide: