2013-01-18 1 views
1

PowerShell v2에서는이 cmdlet Get-EventLog Security | Export-csv C:\file.txt을 사용 중이며 다음과 같은 결과가 표시됩니다.GetEventLog - 'Message'속성을 한 줄에 확장하는 방법

모든 정보를 한 줄로 입력해야합니다. 내 샘플에서 'Message'속성은 여러 줄입니다.

"538","MYPC","System.Byte[]","28330","Accesso/fine sess.","2","SuccessAudit","Fine sessione dell'utente: 

    Nome utente: myusername 

    Dominio:  MYPC 

    ID di accesso: (0x0,0x58C702F) 

    Tipo di accesso: 3 
","Security","System.String[]","538","18/01/2013 10:35:54","18/01/2013 10:35:54","MYPC\myusername",, 

또한 Format-Table로 노력하지만 메시지 필드를 자릅니다.

답변

3

select 필드를 내보낼 자체의 난도질 버전으로 Message 필드를 교체하려면 :

Get-EventLog Security ` 
    | select EventId, ..., @{n='Message';e={$_.Message -replace '\s+', " "}} ` 
    | Export-Csv "C:\file.txt" 
+0

감사합니다. 정확히 내가 필요한 것입니다! – dchamba

-1

내가 멀티 라인 텍스트를 읽고 한 줄 하드로 점점 .. 위의 시도 .. 가공 한 트림 내 사건에 완벽 해.

Get-EventLog Security | 
    Select EventId, ..., @{n='Message';e={$_.Message.trim()}} | 
    Export-Csv "C:\file.csv" 
관련 문제