$EventLog 是错误指示的行中唯一可能是 $null 的东西。如果我尝试执行初始化$EventLog 的命令,我发现它没有返回任何内容...
PS> Get-WmiObject Win32_NTEventlogFile -Filter "LogFileName = 'Security'"
PS>
如果我从 Get-WmiObject 命令中删除 -Filter,这是我作为标准用户在 Windows 10 系统上看到的日志...
PS> Get-WmiObject Win32_NTEventlogFile
FileSize LogfileName Name NumberOfRecords
-------- ----------- ---- ---------------
15798272 Application C:\WINDOWS\System32\Winevt\Logs\Application.evtx 27698
69632 HardwareEvents C:\WINDOWS\System32\Winevt\Logs\HardwareEvents.evtx 0
69632 Internet Explorer C:\WINDOWS\System32\Winevt\Logs\Internet Explorer.evtx 0
69632 Key Management Service C:\WINDOWS\System32\Winevt\Logs\Key Management Service.evtx 0
69632 Parameters C:\WINDOWS\System32\Winevt\Logs\Parameters.evtx 0
69632 State C:\WINDOWS\System32\Winevt\Logs\State.evtx 0
14749696 System C:\WINDOWS\System32\Winevt\Logs\System.evtx 24168
15732736 Windows PowerShell C:\WINDOWS\System32\Winevt\Logs\Windows PowerShell.evtx 10470
...作为提升的用户...
PS> Get-WmiObject Win32_NTEventlogFile
FileSize LogfileName Name NumberOfRecords
-------- ----------- ---- ---------------
15798272 Application C:\WINDOWS\System32\Winevt\Logs\Application.evtx 27698
69632 HardwareEvents C:\WINDOWS\System32\Winevt\Logs\HardwareEvents.evtx 0
69632 Internet Explorer C:\WINDOWS\System32\Winevt\Logs\Internet Explorer.evtx 0
69632 Key Management Service C:\WINDOWS\System32\Winevt\Logs\Key Management Service.evtx 0
69632 Parameters C:\WINDOWS\System32\Winevt\Logs\Parameters.evtx 0
20975616 Security C:\WINDOWS\System32\Winevt\Logs\Security.evtx 29714
69632 State C:\WINDOWS\System32\Winevt\Logs\State.evtx 0
14749696 System C:\WINDOWS\System32\Winevt\Logs\System.evtx 24170
15732736 Windows PowerShell C:\WINDOWS\System32\Winevt\Logs\Windows PowerShell.evtx 10477
请注意,Security 日志仅在 cmdlet 以提升权限运行时可用。因此,如果我以提升的用户身份运行原始命令,它能够访问Security 日志...
PS> Get-WmiObject Win32_NTEventlogFile -Filter "LogFileName = 'Security'"
FileSize LogfileName Name NumberOfRecords
-------- ----------- ---- ---------------
20975616 Security C:\WINDOWS\System32\Winevt\Logs\Security.evtx 29723
来自Event Logging Security...
Security 日志专为系统使用而设计。但是,如果用户被授予SE_SECURITY_NAME 权限(“管理审计和安全日志”用户权限),则用户可以读取和清除Security 日志。