error with limit-eventlog command

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 2 years, 1 month ago.

  • Author
    Posts
  • #19782
    Profile photo of Christopher Cameron
    Christopher Cameron
    Participant

    Hi, I'm going through the Powershell in a Month of Lunches book, and in one lab task in the Appendix it asks me to "run a command that modifies the Security event log to overwrite old events as needed." I run this command,

    limit-eventlog -logname security -overflow overwriteolder

    which I know is the correct cmdlet, but I get this error:

    limit-eventlog : Specify a valid value for the number of retention days.
    At line:1 char:1
    + limit-eventlog -overflowaction OverwriteOlder -logname security
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Limit-EventLog], Exception
    + FullyQualifiedErrorId : InvalidArgument,Microsoft.PowerShell.Commands.LimitEventLogCommand

    Anyone know what I'm doing wrong? There's already a valid value for the number of retention days when I ran

    get-eventlog

    .

  • #19783
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Limit-EventLog requires you to specify a retention period, even if one was previously set. It has to do with the way the underlying .NET stuff works.

You must be logged in to reply to this topic.