error with limit-eventlog command

Welcome Forums General PowerShell Q&A error with limit-eventlog command

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 4 years ago.

  • Author
  • #19782

    Christopher Cameron

    My Achievements

    No Achievements Yet!

    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



  • #19783

    Don Jones

    My Achievements


    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.

Skip to toolbar