본문 바로가기

기술자료/기술운영자료

Windows Power Shell 알아보기 2편 (이벤트 로그 확인)

Windows PowerShell 알아보기


- 2 : Windows PowerShell을 활용한 서버 이벤트 로그 확인

 

Windows Server Core  GUI 환경에서는 Windows PowerShell Get-EventLog cmdlet을 사용하여 서버 내 이벤트 로그를 확인할 수 있습니다.

이번 포스팅 에서는 Get-EventLog cmdlet을 활용한 로그 확인 방법에 대하여 알아보겠습니다.

 

 

Get-EventLog 구문은 아래와 같습니다.

Get-help "Get-EventLog"

이벤트 로그 목록을 볼 수 있습니다.

Get-EventLog -list

 

최근 5개의 시스템 로그를 확인하고 이벤트 메시지 내용을 보기 위해 Format-List cmdlet을 사용

Get-EventLog System -Newest 5

 

Get-EventLog System -Newest 1 | Format-List

 

시스템 이벤트 로그 중 Source 값을 EventLog로 필터링

Get-EventLog System | Where-Object {$_.Source -eq "EventLog"}

 

이벤트 로그 Source(EventLog)와 EventID(6013)에 대한 OR 필터링

Get-EventLog System -Source EventLog | Where-Object {$_.EventID -eq "6013"}

 

Index 번호를 사용한 이벤트 상세 확인 방법

$aone=Get-EventLog System -Index 1390

$aone | Format-List -Property *

 

이벤트 로그 message에 포함된 문자열을 검색하여 해당 정보를 text 파일로 기록

Get-EventLog System -Message "*작동 시간*" //한글 OS인 관계로 한글로 표기/검색 가능

Get-EventLog System -index 1712 | Format-List > d:\uptime.txt

 

이벤트 로그 발생 빈도

$event=Get=EventLog System

$event | Group-Object -Property source -NoElement | Sort-Object -Property Count -Descending

시스템 로그 내의 에러로그만 추려서 확인

Get-EventLog -LogName system -EntryType error

 

참고 사이트

http://technet.microsoft.com/kor-kr/library/dd315250.aspx