我正在尝试创建一个在每次发生事件时都会触发的任务。该事件正在停止winrm服务,当发生这种情况时,它应该触发任务以重新启动它。我可以使用eventviewer界面来做这件事,但我想从命令行来做这件事-这是什么命令?来源: Windows远程管理级别:信息事件ID: 212
任务将启动powershell.exe,参数为ps1脚本
发布于 2015-10-28 19:58:17
试试这个:
$cred = Get-Credential
$password = $cred.GetNetworkCredential().Password
$command = "PowerShell -NoProfile -ExecutionPolicy RemoteSigned " +
"-WindowStyle Hidden -File 'C:\Script.ps1'"
SCHTASKS /Create /TN "Event Monitor" /TR $command /SC ONEVENT `
/RL Highest /RU $cred.Username /RP $password `
/EC ScriptEvents /MO *[Application/EventID=212]https://stackoverflow.com/questions/33390035
复制相似问题