PrtgAPI icon indicating copy to clipboard operation
PrtgAPI copied to clipboard

Unexpected behavior with Get-ObjectLog

Open Silex opened this issue 3 years ago • 1 comments

Describe the bug

This fails:

PS C:\Users\Philippe Vaucher> Get-ObjectLog -Id 2759 -Period Yesterday
Get-ObjectLog : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Get-ObjectLog -Id 2759 -Period Yesterday
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-ObjectLog], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,PrtgAPI.PowerShell.Cmdlets.GetObjectLog

This works:

PS C:\Users\Philippe Vaucher> Get-Sensor -Id 2759 | Get-ObjectLog -Period Yesterday

It's not that big of a deal but I was surprised.

What is the output of 'Get-PrtgClient -Diagnostic'?

PrtgApi 0.9.16 with latest PRTG installation.

Additional context

No response

Silex avatar Jan 24 '22 15:01 Silex

Hi @Silex,

This behavior is intentional, as when I was implementing this I found there was no way to have a parameter set that allows specifying an -Id and -Period that doesn't also cause the PowerShell engine to have issues identifying which parameter set to use when attempting to bind an -Id by itself (which should map to a parameter set with an optional -StartDate and -EndDate)

Having another look at this today, I found a potential way I may be able to resolve this, so I will mark this as a potential Enhancement for now

lordmilko avatar Jan 24 '22 21:01 lordmilko