4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PowerShellでWindowsイベントログを取得する

Last updated at Posted at 2019-06-12

1.最新ログを指定行数分、取得してくる


 Get-EventLog -LogName イベントログ -Newest 行数

 例:Applicationログを新しいものから10行抜き出して表示する

   Get-EventLog -LogName Application -Newest 10

2.指定した期間内のログを取得してくる

 Get-EventLog -LogName  イベントログ -Source イベントソース -After 開始日時 -Before 終了日時

 例:昨日の1日のApplicationログを抜き出す

        $Start=Get-Date (Get-Date).AddDays(-1) -format "yyyy/MM/dd 00:00:00"
        $End=Get-Date (Get-Date).AddDays(-1) -format "yyyy/MM/dd 23:59:59"

  Get-EventLog -LogName Application -source * -After $Start -Before $End

3.Index番号を指定して実行

  Get-EventLog -Logname イベントログ -Index インデックス番号

 例:Applicationログのインデックス番号 190656のログを表示する

   Get-EventLog -LogName Application -index 190656

 例2:Applicationログのインデックス番号 190656のログの詳細を表示する

  (Get-EventLog -LogName Application -index 190656).Message

4.注意事項

 オプションで「-computer」を使用すると、指定したサーバのイベントログも取得することはできるが、場合によっては取得に時間がかかる場合がある。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?