g87616758 发表于 2018-9-2 14:14:21

PowerShell查询WindowsEventLog

$Servers = "yourcomputer1",'"yourcomputer2"  
try
  
{
  
$Arr1 = Get-EventLog System -Entrytype Error -computer $Servers -After (Get-Date).AddDays(-1) | select MachineName,EventID,TimeGenerated,EntryType,Message,Source | ConvertTo-HTML -Fragment
  
}
  
catch
  
{
  
Write-Host "Uh uh, a error occured"
  
}
  
finally
  
{
  
#$CSS = get-content c:\style.css
  
$head1 = "Application Event Logs for Errors$CSS"
  
ConvertTo-HTML -Body "$Arr1" -head $head1 | Out-File d:\System_Event_Logs.html
  
}


页: [1]
查看完整版本: PowerShell查询WindowsEventLog