[英]Scheduled Task PowerShell or CMD script - “Run As Administrator”
I've created a PowerShell script which lists the scheduled tasks and the LastRunResult
.我创建了一个 PowerShell 脚本,其中列出了计划任务和
LastRunResult
。 I'm using Get-ScheduledTask
command.我正在使用
Get-ScheduledTask
命令。 I need to put it at the end of every scheduled task to send a notification related to the LastRunResult
.我需要将它放在每个计划任务的末尾,以发送与
LastRunResult
相关的通知。
The problem is that Get-ScheduledTask
command doesn't work properly and do not show ALL scheduled tasks but just some of them.问题是
Get-ScheduledTask
命令不能正常工作,并且不显示所有计划任务,而只显示其中一些。 To be able to see all scheduled tasks the Get-ScheduledTask
command needs to be run from the CMD or PowerShell console with administrative privileges.为了能够查看所有计划任务,需要从 CMD 或 PowerShell 控制台以管理权限运行
Get-ScheduledTask
命令。 And it works from there.它从那里开始工作。 But it doesn't work when I run such script from Task Scheduler.
但是当我从任务计划程序运行这样的脚本时它不起作用。 Checking
Run with highest privileges
doesn't work. Run with highest privileges
不起作用。 Specifying Policy -Bypass
doesn't work as well.指定
Policy -Bypass
也不起作用。
Does anyone know how to execute Get-ScheduledTask
from Task Scheduler ran in administrator mode to list all scheduled tasks?有谁知道如何从以管理员模式运行的任务计划程序执行
Get-ScheduledTask
以列出所有计划任务?
This can be caused if you have UAC enabled or are logged on as a user who is not an administrator.如果您启用了 UAC 或以非管理员用户身份登录,则可能会导致此问题。 Ensure the runas account is a local administrator.
确保 runas 帐户是本地管理员。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.