I get an error in this resource:
Exception calling "SaveChanges" with "0" argument(s): "The parameter is incorrect"
+ CategoryInfo : NotSpecified: (:) [], CimException
+ FullyQualifiedErrorId : EventLogException
+ PSComputerName : LocalHost
I've added some verbose output to track down which .SaveChanges() method is causing the error. It turns out to be .LogMode property that is causing the error.
I've done some testing with Get-WinEvent on Windows Server 2012 R2 (PS. 5.1) and Windows 10, both have the same results.
I can see the property has changed, but I cannot save the change:
PS C:\> Write-Host "Get log: `n"
$log = Get-WinEvent -ListLog Microsoft-Windows-DeviceSetupManager/Analytic
$log
Write-host "`nChange log mode`n"
$log.LogMode = "Retain"
Write-Host "Check property has changed:`n"
$log
Write-Host "`nSave change:`n"
$log.SaveChanges()
#Output:
Get log:
LogMode MaximumSizeInBytes RecordCount LogName
------- ------------------ ----------- -------
Circular 1052672 Microsoft-Windows-DeviceSetupManager/Analytic
Change log mode
Check property has changed:
Retain 1052672 Microsoft-Windows-DeviceSetupManager/Analytic
Save change:
Exception calling "SaveChanges" with "0" argument(s): "The parameter is incorrect"
At line:12 char:1
+ $log.SaveChanges()
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : EventLogException
In the GUI, I see "Archive the log when full" (AutoBackup) option is grayed out. Also the GUI grays out all options if the log is enabled, so I have made sure the event is disabled, but it still does not allow me to save the setting.
Perhaps as this resource is using the Get-WinEvent and I have shown that Get-WinEvent is the issue, you can't help. Nevertheless, others may have the same issue.
I get an error in this resource:
I've added some verbose output to track down which .SaveChanges() method is causing the error. It turns out to be .LogMode property that is causing the error.
I've done some testing with Get-WinEvent on Windows Server 2012 R2 (PS. 5.1) and Windows 10, both have the same results.
I can see the property has changed, but I cannot save the change:
In the GUI, I see "Archive the log when full" (AutoBackup) option is grayed out. Also the GUI grays out all options if the log is enabled, so I have made sure the event is disabled, but it still does not allow me to save the setting.
Perhaps as this resource is using the Get-WinEvent and I have shown that Get-WinEvent is the issue, you can't help. Nevertheless, others may have the same issue.