PrtgAPI
PrtgAPI copied to clipboard
Get-ObjectProperty : Could not deserialize value 'WriteResultToDisk' as it is not a valid member of type 'PrtgAPI.DebugMode'
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`
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
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
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
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.
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
If the sensor name contains wildcard characters that can cause an issue: specifically *
, ?
, [
and ]
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
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?