SOLVED

Read value from variable after converting from JSON

Iron Contributor

Hi,

I'm developing my first scripts to read data from Defender 365 Hunting queries and then use those values to be stored on a variable and sent over by email for some reports.

For example, now I've got the result from a query, which after parsing the JSON with the command:

$vulnData = $vulnResponse.Content | ConvertFrom-Json

Then, I've got this on $vulnData variable:

email address removed for privacy reasons Count
----------------         -----
#Int64                      100

 

How can I extract the number to a variable?

Thanks

4 Replies
$vulnData.Count should give you 100. You can set it to another variable if needed by using $number=$vulnData.Count

@Harm_Veenstra 

Hi,

That was what I was expecting, but in fact when I do a $vulnData.Count I get a value of 1, instead of the value which is contained.

Am I missing something obvious here?

best response confirmed by dmarquesgn (Iron Contributor)
Solution
:beaming_face_with_smiling_eyes: The .Count method does a count and that's one. Perhaps putting 's around it would help?

@Harm_Veenstra 

After digging a bit this worked out.

$vulnData.results.GetValue(0).Count
 
Thanks
1 best response

Accepted Solutions
best response confirmed by dmarquesgn (Iron Contributor)
Solution
:beaming_face_with_smiling_eyes: The .Count method does a count and that's one. Perhaps putting 's around it would help?

View solution in original post