用powershell命令监听系统日志的变化:
while ($true) {
$event = Get-WinEvent -LogName System -MaxEvents 1
if ($event) {
Write-Host "New event detected: $($event.Message)"
}
Start-Sleep -Seconds 5 # 调整轮询的时间间隔
}
用powershell命令监听系统日志的变化:
while ($true) {
$event = Get-WinEvent -LogName System -MaxEvents 1
if ($event) {
Write-Host "New event detected: $($event.Message)"
}
Start-Sleep -Seconds 5 # 调整轮询的时间间隔
}