イベントログの内容を表示する(取得する)Get-EventLogについて以下に記します。
PowerShell ISEでGet-EventLog -LogName と入力すると以下のスクリーンショットが表示されます。
各種イベントを指定して取得することができます。
尚、上記のLogNameのリストは以下のように一覧を表示することができます。(-List)
PS D:\ps> Get-EventLog -List Max(K) Retain OverflowAction Entries Log ------ ------ -------------- ------- --- 20,480 0 OverwriteAsNeeded 5,747 Application 20,480 0 OverwriteAsNeeded 0 HardwareEvents 512 7 OverwriteOlder 0 Internet Explorer 20,480 0 OverwriteAsNeeded 0 Key Management Service 128 0 OverwriteAsNeeded 11 OAlerts Security 20,480 0 OverwriteAsNeeded 4,048 System 15,360 0 OverwriteAsNeeded 108 Windows PowerShell
Get-Help Get-EventLogでみると以下の様な構文になります。
> Get-Help Get-EventLog 名前 Get-EventLog 構文 Get-EventLog [-LogName] <string> [[-InstanceId] <long[]>] [-ComputerName <string[]>] [-Newest <int>] [-After <datetime>] [-Before <datetime>] [-UserName <string[]>] [-Index <int[]>] [-EntryType <string[]> {Error | In formation | FailureAudit | SuccessAudit | Warning}] [-Source <string[]>] [-Message <string>] [-AsBaseObject] [<CommonParameters>] Get-EventLog [-ComputerName <string[]>] [-List] [-AsString] [<CommonParameters>]
上記の-Newestを例に実際に実行してみます。
PS D:\> Get-EventLog -LogName Application -Newest 3 Index Time EntryType Source InstanceID Message ----- ---- --------- ------ ---------- ------- 6397 3 31 11:12 Information Microsoft-Windows... 2003 The Windows Location Provider has succes... 6396 3 31 11:12 Information Microsoft-Windows... 2001 The Windows Location Provider has succes... 6395 3 31 11:10 Information Microsoft-Windows... 2003 The Windows Location Provider has succes...
PS D:\> Get-EventLog -LogName System -Newest 3 Index Time EntryType Source InstanceID Message ----- ---- --------- ------ ---------- ------- 5148 3 31 10:42 Information Service Control M... 1073748864 Background Intelligent Transfer Service ... 5147 3 31 10:39 Information Microsoft-Windows... 507 ソース 'Microsoft-Windows-Kernel-Power' のイベ... 5146 3 31 10:33 Information Microsoft-Windows... 506 ソース 'Microsoft-Windows-Kernel-Power' のイベ...
以上、PowerShellでEvent Logを確認するGet-EventLogコマンドレットの紹介でした。