Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-ObjectProperty : Could not deserialize value 'WriteResultToDisk' as it is not a valid member of type 'PrtgAPI.DebugMode' #333

Open
MikeSouthwell opened this issue May 15, 2023 · 8 comments

Comments

@MikeSouthwell
Copy link

MikeSouthwell commented May 15, 2023

Can someone please assist with the following error?

I'm trying to customise the "microsoft365sensor" type. However, when I try to pipe Get-Object Property to Get-Sensor it throws the following error (I want to change the Search for field under Filter by Subject, but I don't know what the -RawProperty would be):

`Get-Sensor -Name $clientSubject | Get-ObjectProperty

Get-ObjectProperty : Could not deserialize value 'WriteResultToDisk' as it is not a valid member of type 'PrtgAPI.DebugMode'. Could not process XML '<injected_writeresult>WriteResultToDisk</injected_writeresult>'.
At line:1 char:35

  • Get-Sensor -Name $clientSubject | Get-ObjectProperty
    • CategoryInfo : NotSpecified: (:) [Get-ObjectProperty], XmlDeserializationException
    • FullyQualifiedErrorId : PrtgAPI.XmlDeserializationException,PrtgAPI.PowerShell.Cmdlets.GetObjectProperty`
@lordmilko
Copy link
Owner

The DebugMode property of a given object has historically been one of the following three values on several sensor types:

  • Discard
  • WriteToDisk
  • WriteToDiskWhenError

You can see that "WriteResultToDisk" is slightly different. I will need to investigate whether this is unique to this sensor type or PRTG have renamed one of the previous historical values

In the meantime, you can work around this by instead asking PrtgAPI to emit raw object properties

Get-Sensor $clientSubject | Get-ObjectProperty -Raw

@MikeSouthwell
Copy link
Author

Thanks lordmilko,

When I try and run that command it doesn't return anything.

It could be that that sensor type doesn't have any Raw values?

I just want to change the Search for field value under Filter by Subject

@lordmilko
Copy link
Owner

Can you confirm that Get-Sensor $clientSubject returns something?

You will need to set the $clientSubject variable again if you execute this in a fresh PowerShell session

@MikeSouthwell
Copy link
Author

It doesn't return anything, but it doesn't return an error either. The $clientSubject variable is working and I have confirmed that when I just run $clientSubject it does output the intended variable it is storing.

@lordmilko
Copy link
Owner

lordmilko commented May 16, 2023

This (likely) means the $clientSubject variable does not exactly match the name of the sensor

For the purposes of this issue, can you try and do Get-Sensor -Id <id> instead, where ID is the ID of the sensor shown in the URL, then do Get-Sensor -Id <id> | Get-ObjectProperty -Raw

@lordmilko
Copy link
Owner

If the sensor name contains wildcard characters that can cause an issue: specifically *, ?, [ and ]

@MikeSouthwell
Copy link
Author

I got it working now. Thanks @lordmilko!

For anyone else, this is the PowerShell code required:

Get-Sensor -Name $clientSubject | Set-ObjectProperty -RawProperty paessler-microsoft365-mailbox_section-mailbox_group-filter_subject_string_ -RawValue "$subjectString" -Force

@Timmeeh
Copy link

Timmeeh commented May 13, 2024

I get a similar result for the sensors of type REST Custom v2 (BETA). PRTG 24.1.92.1554.

get-sensor -tags rest | Get-ObjectProperty -RawProperty writeresult returns DiscardResult for all ~100 of them.

So it seems some PRTG sensors can now also return a string instead of integer values?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants