error with limit-eventlog command

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
.

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.