powershell 2.0无法获取Internet Explorer日志

时间:2012-04-25 16:22:13

标签: powershell powershell-v2.0 event-log

当我尝试在powershell V2.0的win2003 std上运行cmd get-eventlog -list。 它给了我以下输出

 Max(K) Retain OverflowAction        Entries Log
 ------ ------ --------------        ------- ---
 16,384      0 OverwriteAsNeeded         117 Application
 512      7 OverwriteOlder              0 Internet Explorer
 20,480      0 OverwriteAsNeeded           0 Microsoft-Windows-Forwarding/Operational
 16,384      0 OverwriteAsNeeded         136 Security
 16,384      0 OverwriteAsNeeded         173 System
 15,360      0 OverwriteAsNeeded          83 Windows PowerShell

当尝试运行get-eventlog“Internet Explorer”时,它会给我错误

Get-EventLog : No matches found
At line:1 char:13
+ get-eventlog <<<<   $event
    + CategoryInfo          : ObjectNotFound: (:) [Get-EventLog], ArgumentException
    + FullyQualifiedErrorId : GetEventLogNoEntriesFound,Microsoft.PowerShell.Commands.GetEventLogCommand

有人可以帮我解决问题吗?

2 个答案:

答案 0 :(得分:0)

这只是因为你的日志目前是空的!

答案 1 :(得分:0)

你得到异常,因为它是空的,但是你仍然可以通过这样做来获得对象:

$ieLog = get-eventlog -list | where-object {$_.Log -eq "Internet Explorer"}

要验证您确实获得了正确的日志,请尝试在其中写一些内容:

$ieLog.Source = "Testing"
$ieLog.WriteEntry("Write Succeeded")