从下面的代码行中,有没有一种方法可以调用.txt文件来查看要查看的计算机列表?我希望它不仅在一台计算机中查找日志,而且从计算机列表中查找日志。
$StartDate = (get-date).AddHours(-12)
Get-WinEvent -FilterHashtable @{logname="System"; Level=1,2,3; starttime=$StartDate} -ErrorAction SilentlyContinue
希望早日收到你的消息!谢谢。
由于cmdlet的-ComputerName
参数Get-WinEvent
仅接受字符串,因此您可能必须遍历列表:
$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
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句