[BUG] System.ArgumentException cmpivot
PaulDHaes opened this issue · 1 comments
Describe the bug
CMPivot query for reading file content System.ArgumentException error.
An unhandled exception of type System.ArgumentException occurred: Accessed JArray values with invalid key value: "Result" . Int32 array index expected. When executing
To Reproduce
Steps to reproduce the behavior:
- Build latest content.
- Execute On GW1
. \SharpSCCM_merged.exe invoke admin-service -q "FileContent ('C: \Windows\system32\drivers\etc\hosts')" -i SMS00001 -mp 192.168.1.110 --no-banner -d 10
- Wait a few seconds and scroll down.
- See error
Expected behavior
The full output that was seen by using the web browser was not displayed in the console. Instead, it throws an error.
If you add the -j to display it in JSON it works but the format is a not good for reading the file content of a file.
** SharpSCCM version**
branch version ba23103
normally latest.
** Management point server specs (please complete the following information):**
- OS: Windows Server 2019
- ConfigMgr Version: 2111, Site version 5.0.9049.1000
Client specs (please complete the following information):
- OS: Windows 10 GW-1
- ConfigMgr Version 5.00.9049.1010
Additional context
On line 203 in the SharpSCCM.AdminService file the code is like this.
JArray results = (JArray)obj["value"]["Result"];
To fix the issue, it should be like this.
JArray results = (JArray)obj["value"][0]["Result"];
@PaulDHaes , thank you so much for the detailed bug report and for the massive delay. I lost track of this and haven't had time to get this fixed until now, but this has been fixed in PR #49 . I found several other issues while investigating this so ended up rewriting the JSON parsing logic entirely.