Многие описания событий для событий журнала отсутствуют, когда я запрашиваю их в PowerShell с помощью Get-EventLog, но они присутствуют когда я запрашиваю их в PowerShell с помощью Get-WinEvent или просматриваю в обычном средстве просмотра событий eventvwr.msc
Вот результат Get-EventLog:
PS U:\> Get-EventLog -LogName System -Source Microsoft-Windows-Kernel-Power
Index Time EntryType Source InstanceID Message
----- ---- --------- ------ ---------- -------
11985 Apr 02 13:42 Information Microsoft-Windows... 172 The description for Event ID '172' in Source 'Microsoft-Windo...
11968 Apr 02 13:41 Information Microsoft-Windows... 109 The description for Event ID '109' in Source 'Microsoft-Windo...
11732 Apr 02 09:41 Information Microsoft-Windows... 172 The description for Event ID '172' in Source 'Microsoft-Windo...
11714 Apr 02 09:40 Information Microsoft-Windows... 109 The description for Event ID '109' in Source 'Microsoft-Windo...
10363 Mar 29 14:28 Information Microsoft-Windows... 172 The description for Event ID '172' in Source 'Microsoft-Windo...
10346 Mar 29 14:28 Information Microsoft-Windows... 109 The description for Event ID '109' in Source 'Microsoft-Windo...
Вот полное событие:
PS U:\> Get-EventLog -LogName System -Source Microsoft-Windows-Kernel-Power | select -first 1 | fl
Index : 11985
EntryType : Information
InstanceId : 172
Message : The description for Event ID '172' in Source 'Microsoft-Windows-Kernel-Power' cannot be found. The local
computer may not have the necessary registry information or message DLL files to display the message, or you
may not have permission to access them. The following information is part of the event:'2', '6'
Category : (203)
CategoryNumber : 203
ReplacementStrings : {2, 6}
Source : Microsoft-Windows-Kernel-Power
TimeGenerated : 2019-04-02 13:42:01
TimeWritten : 2019-04-02 13:42:01
UserName : NT AUTHORITY\SYSTEM
Вот результат Get-WinEvent :
PS C:\WINDOWS\system32> Get-WinEvent -LogName System -FilterXPath "<QueryList>
>> <Query Id='0' Path='System'>
>> <Select Path='System'>*[System[Provider[@Name='Microsoft-Windows-Kernel-Power']]]</Select>
>> </Query>
>> </QueryList>"
ProviderName: Microsoft-Windows-Kernel-Power
TimeCreated Id LevelDisplayName Message
----------- -- ---------------- -------
2019-04-02 13:42:01 172 Information Connectivity state in standby: Disconnected, Reason: NIC compliance
2019-04-02 13:41:44 109 Information The kernel power manager has initiated a shutdown transition....
2019-04-02 09:41:08 172 Information Connectivity state in standby: Disconnected, Reason: NIC compliance
2019-04-02 09:40:51 109 Information The kernel power manager has initiated a shutdown transition....
2019-03-29 14:28:26 172 Information Connectivity state in standby: Disconnected, Reason: NIC compliance
2019-03-29 14:28:09 109 Information The kernel power manager has initiated a shutdown transition....
Get-WinEvent может отображать сообщение «Состояние подключения в режиме ожидания: отключено, причина: NIC comp. liance "без проблем.
Вот первое событие в средстве просмотра событий, сообщение также отображается правильно:
Сообщение предполагает, что реестр или файл dll сообщения о событии могут быть проблемой, но я проверил, и они не 't:
PS U:\> Get-ItemPropertyValue HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\System\Microsoft-Windows-Kernel-Power -name EventMessageFile
C:\WINDOWS\system32\microsoft-windows-kernel-power-events.dll
PS U:\> test-path C:\WINDOWS\system32\microsoft-windows-kernel-power-events.dll
True
PS U:\> $handle = [System.IO.File]::OpenRead("C:\WINDOWS\system32\microsoft-windows-kernel-power-events.dll")
PS U:\> $handle.CanRead
True
Это показывает, что
Он не изолирован от источника Microsoft-Windows-Kernel-Power . То же самое происходит со многими другими источниками событий. Но не все источники событий. Например, Get-EventLog правильно отображает исходные сообщения Microsoft-Windows-Winlogon:
PS U:\> Get-EventLog -LogName System -Source Microsoft-Windows-Winlogon | select -first 1 | ft
Index Time EntryType Source InstanceID Message
----- ---- --------- ------ ---------- -------
12100 Apr 02 13:58 Information Microsoft-Windows... 7001 User Logon Notification for Customer Experience Improvement P...
Я уже несколько раз перезагружал свой компьютер, я запускал средство проверки системных файлов, и оно не сообщило о проблемах.
Сведения о версии:
PS U:\> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.316
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.316
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Я лічу, што вы сутыкнуліся з абмежаваннямі пры дапамозе камандлета Get-EventLog, які быў заменены камандлетам Get-WinEvent. Згодна з афіцыйнай дакументацыяй:
Камандлеты PowerShell, якія ўтрымліваюць назоўнік EventLog, працуюць толькі ў класічных часопісах падзей Windows, такіх як Application, System або Security. Каб атрымаць часопісы, якія выкарыстоўваюць тэхналогію часопіса падзей Windows у Windows Vista і больш позніх версіях Windows, выкарыстоўвайце Get-WinEvent.
Хоць вы запытваеце сістэмны журнал падзей, на які гэта тэхнічна не павінна ўплываць, бо гэта класічны часопіс падзей, тыя тыпы запісаў у журнале падзей (якія пачынаюцца з Microsoft -Windows-
) пачаў з'яўляцца толькі ў Vista і пазней, таму я ўпэўнены, што гэта "па задуме".
Я, шчыра кажучы, не ўпэўнены, чаму вы не проста карыстаецеся Get- Камандлет WinEvent
замест гэтага, бо гэты сапраўды працуе.