Which of the below CmdLet will clear all the entries inside “MyLog” in the Eventlog section of a Local/Remote Server?
-
$RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog Application, $computername $RemoteAppLog.Clear()
-
$RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog MyLog,$computername $RemoteAppLog.Remove()
-
$RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog MyLog,$computername $RemoteAppLog.Delete()
-
$RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog MyLog,$computername $RemoteAppLog.Clear()
D
Correct answer
Explanation
Option D correctly instantiates System.Diagnostics.EventLog with the log name MyLog and calls the Clear() method to remove all entries. Options A uses the wrong log name (Application), while B and C use incorrect methods (Remove() and Delete() don't exist or don't clear entries).