Get-WinEvent 多台电脑日志监控
Log Monitoring of Multiple Computers with Get-WinEvent
从下面的代码行中,是否有办法调用一个 .txt 文件来获取要查看的计算机列表?我希望它不仅在一台计算机中而且在计算机列表中查找日志。
$StartDate = (get-date).AddHours(-12)
Get-WinEvent -FilterHashtable @{logname="System"; Level=1,2,3; starttime=$StartDate} -ErrorAction SilentlyContinue
希望尽快收到您的来信!谢谢
由于 Get-WinEvent
cmdlet 的 -ComputerName
参数只接受一个字符串,您可能需要遍历列表:
$StartDate = (get-date).AddHours(-12)
Get-Content 'computers.txt' | ForEach-Object {
Get-WinEvent -ComputerName $_ -FilterHashtable @{logname="System"; Level=1,2,3; starttime=$StartDate} -ErrorAction SilentlyContinue
}
从下面的代码行中,是否有办法调用一个 .txt 文件来获取要查看的计算机列表?我希望它不仅在一台计算机中而且在计算机列表中查找日志。
$StartDate = (get-date).AddHours(-12)
Get-WinEvent -FilterHashtable @{logname="System"; Level=1,2,3; starttime=$StartDate} -ErrorAction SilentlyContinue
希望尽快收到您的来信!谢谢
由于 Get-WinEvent
cmdlet 的 -ComputerName
参数只接受一个字符串,您可能需要遍历列表:
$StartDate = (get-date).AddHours(-12)
Get-Content 'computers.txt' | ForEach-Object {
Get-WinEvent -ComputerName $_ -FilterHashtable @{logname="System"; Level=1,2,3; starttime=$StartDate} -ErrorAction SilentlyContinue
}