2017-01-23 115 views
0

我嘗試寫入事件日誌「應用程序」。我用了ScriptingGuy-Tutorial。如博客中所述,我使用以下命令在「以管理員身份運行」中註冊源「ScS」--Powershell: New-EventLog -logname Application -source "ScS"寫事件日誌不寫入應用程序日誌(註冊優先源後)

我沒有收到錯誤消息或任何其他反饋。在註冊表中我可以看到源路徑

HKLM\System\CurrentControlSet\Services\EventLog\Application\ScS 

enter image description here

在那之後,我試着寫一個事件:

write-eventlog -logname Application -Source "ScS" -EntryType Information -EventId 01 -Message "Test" 

我沒有收到一個錯誤。但它不寫這個事件。我沒有看到它在eventvwr也沒有在shell中,使用get-eventlog -LogName Application -Source "ScS"

我使用Win 8.1 Pro(德語)與Powershell 4.0。希望你能告訴我我的錯誤...

回答

0

你失去了第一個調用中的日誌名稱是你想創建的日誌名稱「Application」是現有日誌的事實。

下面是一個例子(PowerShell的V2有它自己的小命令):

# List of logs 
Get-EventLog -list 

# Creating your own log 
New-EventLog -LogName "SlxScripting" -Source "MaSource" 

# List of logs 
Get-EventLog -list 

# Writting in your own log 
Write-EventLog -LogName "SlxScripting" -EventId 12 ` 
       -Message "Mon Message" 
       -Source "MaSource" -EntryType Warning 

# Reading (consuming) in your own log 
Get-EventLog -LogName "SlxScripting" 

# Suppressing your log (if needed) 
Remove-EventLog -LogName "SlxScripting"