Open BartoPhotographer opened 4 months ago
Hey, did you check the powershell x86 and x64 execution policy?
If policy is right I would try to execute it directly in Powershell.
Hi, I´ve checked the execution policy. Should be okay. When I execute it directly in Powershell I get:
Remove-Variable : Cannot find a variable with the name 'ProxyCreds'. At C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-M365-AppSecrets.ps1:90 char:5
+ CategoryInfo : ObjectNotFound: (ProxyCreds:String) [Remove-Variable], ItemNotFoundException
+ FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand
Token not found, going to renew Token sucessfully got new MS Graph Token
On 20. Jun 2024, at 19:58, Jannos-443 @.***> wrote:
Hey, did you check the powershell x86 and x64 execution policy?
If policy is right I would try to execute it directly in Powershell.
— Reply to this email directly, view it on GitHub https://github.com/Jannos-443/PRTG-M365/issues/13#issuecomment-2181240842, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT6CKPPHLVDHQOT5RXGCBX3ZIMJ5ZAVCNFSM6AAAAABJUG37ZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBRGI2DAOBUGI. You are receiving this because you authored the thread.
If I comment out the text section, I no longer get an error.
thats interessting, could you send me the LOG from the PRTG Sensor itself after getting this error? Maybe we can see the issue in the log.
Store result: Store the last sensor result in the \Logs\sensors subfolder of the PRTG data directory on the probe system. The file names are Result of Sensor [ID].txt and Result of Sensor [ID].Data.txt. This setting is for debugging purposes. PRTG overwrites these files with each scanning interval.
you could also try to add a -ErrorAction SilentlyContinue
in line 73 but I guess this will not help.
Remove-Variable ProxyAddress -ErrorAction SilentlyContinue
I´ve attached the log. The error doesn´t occur if I set the $Top5 to "-First 3” So it seems there is a problem with the 4th entry. Perhaps the blanks in the secret name?

On 29. Jun 2024, at 20:08, Jannos-443 @.***> wrote:
thats interessting, could you send me the LOG from the PRTG Sensor itself after getting this error? Maybe we can see the issue in the log.
Store result: Store the last sensor result in the \Logs\sensors subfolder of the PRTG data directory https://www.paessler.com/manuals/prtg/data_storage#data on the probe system. The file names are Result of Sensor [ID].txt and Result of Sensor [ID].Data.txt. This setting is for debugging purposes. PRTG overwrites these files with each scanning interval.
you could also try to add a -ErrorAction SilentlyContinue in line 73 but I guess this will not help. Remove-Variable ProxyAddress -ErrorAction SilentlyContinue
— Reply to this email directly, view it on GitHub https://github.com/Jannos-443/PRTG-M365/issues/13#issuecomment-2198280936, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT6CKPOMH7LSF6H6DOHSEWDZJ3Z2TAVCNFSM6AAAAABJUG37ZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYGI4DAOJTGY. You are receiving this because you authored the thread.
Great script, thanks for all your effort for creating this script!
I tried the latest script and also got the same error message as BartoPhotographer in PRTG. I could succesfully execute the script from powershell and there was nothing wrong with the XML file output. I was lazy so I let Copilot (GPT) have a run for syntax issues and it corrected the script. The script is now working for me
I also added 2 filters for known issues with expired secrets. One of those is the behaviour of Azure AD proxy and the CWAP_AuthSecret.
I proposed the changes i've made from my fork. I'm running that script succesfully now in our PRTG environment
@BartoPhotographer could you check if this change fixes your issue?
Hi,
Sorry, but I still get the same error:
XML: Structural error in xml file, 2 open items. -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)
Kind regards Matthias
On 10. Jul 2024, at 22:41, Jannos-443 @.***> wrote:
@BartoPhotographer https://github.com/BartoPhotographer could you check if this change fixes your issue?
— Reply to this email directly, view it on GitHub https://github.com/Jannos-443/PRTG-M365/issues/13#issuecomment-2221410418, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT6CKPPWF66565W7TDH5QT3ZLWL7RAVCNFSM6AAAAABJUG37ZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRRGQYTANBRHA. You are receiving this because you were mentioned.
I was having the same issue as above, i commented out the secretdisplayname and it all ran fine after that line 283, i now have the below:
<#
foreach ($Top in $Top5) {
$OutputText += "App `"$($Top.AppDisplayname)`" Secret `"$($Top.SecretDisplayname)`" expires in $($Top.DaysLeft)d; "
}
#>
foreach ($Top in $Top5) {
$OutputText += "App `"$($Top.AppDisplayname)`" expires in $($Top.DaysLeft)d; "
}
Same here. Works fine if we comment out the SecretDisplayname
On 11. Jul 2024, at 12:51, stephencrw @.***> wrote:
I was having the same issue as above, i commented out the secretdisplayname and it all ran fine after that line 283, i now have the below:
<# foreach ($Top in $Top5) { $OutputText += "App
"$($Top.AppDisplayname)
" Secret"$($Top.SecretDisplayname)
" expires in $($Top.DaysLeft)d; " }>
foreach ($Top in $Top5) { $OutputText += "App
"$($Top.AppDisplayname)
" expires in $($Top.DaysLeft)d; " } — Reply to this email directly, view it on GitHub https://github.com/Jannos-443/PRTG-M365/issues/13#issuecomment-2222618411, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT6CKPNRO3STRN5IWQADAFLZLZPTXAVCNFSM6AAAAABJUG37ZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRSGYYTQNBRGE. You are receiving this because you were mentioned.
Hi, Sorry, but I still get the same error: XML: Structural error in xml file, 2 open items. -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231) Kind regards Matthias
@BartoPhotographer could you provide your complete logfile for this error? Currently I cannot create this error
On 11. Jul 2024, at 22:53, Jannos-443 @.***> wrote:
Hi, Sorry, but I still get the same error: XML: Structural error in xml file, 2 open items. -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231) Kind regards Matthias
@BartoPhotographer https://github.com/BartoPhotographer could you provide your complete logfile for this error? Currently I cannot create this error
— Reply to this email directly, view it on GitHub https://github.com/Jannos-443/PRTG-M365/issues/13#issuecomment-2223921161, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT6CKPLVW7FMO35WF277GLTZL3WEDAVCNFSM6AAAAABJUG37ZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRTHEZDCMJWGE. You are receiving this because you were mentioned.
Hi,
I had the same issue. I commented out the "Write-Host" lines between line 129 and 155. Works fine afterwards. The lines are great for troubleshooting, less so afterwards.
Hey,
I did not expect the debug output to become a problem. I removed it, hopefully this works better now.
Hi, I am still getting the error "XML: Structural error in xml file, 2 open items. -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)". In Powershell it's working fine.
I checked the execution policy (unrestricted) and even signed the script. Unfortunately the logs folder (C:\ProgramData\Paessler\PRTG Network Monitor\Logs\sensors) is empty. I am using Hosted PRTG. Do you have any ideas? Thanks and BR
Hi, I am still getting the error "XML: Structural error in xml file, 2 open items. -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)". In Powershell it's working fine.
I checked the execution policy (unrestricted) and even signed the script. Unfortunately the logs folder (C:\ProgramData\Paessler\PRTG Network Monitor\Logs\sensors) is empty. I am using Hosted PRTG. Do you have any ideas? Thanks and BR
OK, i deleted many of the expired secrets in our Azure tenant and now it's working! Is there maybe an issue with high numbers of expired secrets?
Hi. I also still get the error...
On 12. Aug 2024, at 13:53, webwob007 @.***> wrote:
Hi, I am still getting the error "XML: Structural error in xml file, 2 open items. -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)". In Powershell it's working fine.
I checked the execution policy (unrestricted) and even signed the script. Unfortunately the logs folder (C:\ProgramData\Paessler\PRTG Network Monitor\Logs\sensors) is empty. I am using Hosted PRTG. Do you have any ideas? Thanks and BR
OK, i deleted many of the expired secrets in our Azure tenant and now it's working! Is there maybe an issue with high numbers of expired secrets?
— Reply to this email directly, view it on GitHub https://github.com/Jannos-443/PRTG-M365/issues/13#issuecomment-2283764886, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT6CKPK66KDARX3NEUAK5KLZRCO3NAVCNFSM6AAAAABJUG37ZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBTG43DIOBYGY. You are receiving this because you were mentioned.
M365 License Check - PRTG Error PE233 and PE231
Hey all, im still getting the error when attempting to run the License check script. Exec policies (x86 and x64) are unrestricted, and i can execute no issues directly from powershell.
Powershell output: (redacted and trimmed to fit)
PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> .\PRTG-M365-Licenses.ps1 -ApplicationID 'xxxx-xxxx-xxxx-xxxx-xxxx' -TenantID 'xxxx-xxxx-xxxx-xxxx-xxxx' -AccessSecret 'xxxxxxxxxxxxxxxxxxxx'
<prtg>
<result>
<channel>LastDirSync</channel>
<value>1198</value>
<unit>TimeSeconds</unit>
<limitmode>1</limitmode>
<LimitMaxError>7200</LimitMaxError>
</result><text>Groups with License Errors: group: DG-License-O365-E3 errors: 7; </text>
<result>
<channel>GroupBasedLicenseError</channel>
<value>1</value>
<unit>Count</unit>
<limitmode>1</limitmode>
<LimitMaxError>0</LimitMaxError>
</result>
<result>
<channel>VISIOCLIENT - Total Licenses</channel>
<value>5</value>
<unit>Count</unit>
</result>
<result>
<channel>AAD_PREMIUM_P2 - Total Licenses</channel>
<value>1175</value>
<unit>Count</unit>
</result>
<result>
<channel>POWER_BI_STANDARD - Free Licenses</channel>
<value>997117</value>
<unit>Count</unit>
</result>
</prtg>
PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML>
when i run the sensor direct from PRTG, using same AppID, Tennant and ClientSecret, it returns our favourite error:
XML: The returned XML does not match the expected schema. (code: PE233) -- JSON: The returned JSON does not match the expected structure (#O2). (code: PE231)
Even though i enabled "store result" i get nothing within files in the error log folder. the .Data file contains data but the log is blank.
Any ideas?
Cheers Tim
@Jannos-443 https://github.com/Jannos-443: Any ideas what I can try? I still get the same error. No problem when I uncomment the SecretDisplayname
On 12. Aug 2024, at 14:54, Matthias Pohl @.***> wrote:
Hi. I also still get the error...
On 12. Aug 2024, at 13:53, webwob007 @.***> wrote:
Hi, I am still getting the error "XML: Structural error in xml file, 2 open items. -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)". In Powershell it's working fine.
I checked the execution policy (unrestricted) and even signed the script. Unfortunately the logs folder (C:\ProgramData\Paessler\PRTG Network Monitor\Logs\sensors) is empty. I am using Hosted PRTG. Do you have any ideas? Thanks and BR
OK, i deleted many of the expired secrets in our Azure tenant and now it's working! Is there maybe an issue with high numbers of expired secrets?
— Reply to this email directly, view it on GitHub https://github.com/Jannos-443/PRTG-M365/issues/13#issuecomment-2283764886, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT6CKPK66KDARX3NEUAK5KLZRCO3NAVCNFSM6AAAAABJUG37ZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBTG43DIOBYGY. You are receiving this because you were mentioned.
@BartoPhotographer could you try again with the latest one? Maybe removing the debug output and cutting the output text will help.
Sorry, but still the same:
XML: Structural error in xml file, 2 open items. -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)
On 10. Sep 2024, at 20:01, Jannos-443 @.***> wrote:
@BartoPhotographer https://github.com/BartoPhotographer could you try again with the latest one? Maybe removing the debug output and cutting the output text will help.
— Reply to this email directly, view it on GitHub https://github.com/Jannos-443/PRTG-M365/issues/13#issuecomment-2341629355, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT6CKPJESRVYYHSFBZIZU3TZV4XXDAVCNFSM6AAAAABJUG37ZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBRGYZDSMZVGU. You are receiving this because you were mentioned.
Hi, thx for your work! I get the following error with the M365 sensor:
XML: Structural error in xml file, 2 open items. -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)
Any idea?