none
[PowerShell] : Help required for executing a power shell script with parameters.

    Question

  • I am new to power shell scripting.

    Requirement : To get the event logs after a given time with some basic filter criteria (Event id, Log Name, etc..)

    I am executing using the below

    PS C:\Users\ssahu\Desktop> .\GetEventLogs.ps1 System , 2/10/2015 ,6013

    Below is the the error I am encountering :

    Get-EventLog : Cannot bind parameter 'After'. Cannot convert value "" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."

    At C:\Users\ssahu\Desktop\GetEventLogs.ps1:9 char:41

    + Get-EventLog -LogName "$LogName" -After "$fromDate" | where{$_.EventID -eq "$Eve ...

    +                                         ~~~~~~~~~~~

        + CategoryInfo          : InvalidArgument: (:) [Get-EventLog], ParameterBindingException

        + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetEventLogCommand

    Please help ..thanks in advance !!!

    • Moved by Just KarlModerator Tuesday, February 17, 2015 10:55 PM Looking for the proper forum.
    Thursday, February 12, 2015 1:04 PM

Answers