![](/img/trans.png)
[英]how can i save event log information in a excel using powershell
[英]How can I select Event log by their InstanceID
我想获取有关系统和错误的所有EventLog条目。 在这些条目中,我想通过它们的特定InstanceID选择它们。
我正在使用一个管道,在其中过滤器变薄,但是我不知道如何将InstanceID与我想要的InstanceID的值进行比较。
$sysLog = Get-EventLog -LogName System -EntryType Error |
Where-Object{$_.InstanceId = 10016}
+ ... LogName System -EntryType Error | Where-Object{$_.InstanceId = 10016} + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation : (:) [], RuntimeException + FullyQualifiedErrorId : PropertyAssignmentException
我认为代码工作:
$sysLog = Get-EventLog -LogName System -EntryType Error | Where-Object{$_.InstanceId -eq 10016}
$sysLog
请参阅: https : //docs.microsoft.com/zh-cn/powershell/module/microsoft.powershell.core/about/about_comparison_operators?view=powershell-6
导出到日志文件的EDIT示例:
Function WriteEventLogFile ([string] $pathToWriteLog, [string] $InstanceId){
$sysLogItems = Get-EventLog -LogName System -EntryType Error | Where-Object {$_.InstanceId -eq $InstanceId}
# write-host $sysLogItems
$sysLogItems | Export-Csv -Path $pathToWriteLog -NoTypeInformation
}
WriteEventLogFile -pathToWriteLog:"C:\Temp\envent_export.log" -InstanceId:"10016"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.