Hello,
I wrote small script for extracting IP addresses from JSON file. File has structure like below:
<span style="font-size: 10pt">{
"origin": "aaa",
"category": "aaa",
"confidence": "aaa",
"name": "aaa",
"proto": "tcp",
"address": [
{
"cc": "PL",
"ip": "111.111.111.111",
"asn": 0000
}
],
"source": "aaa",
"time": "2020-02-25T07:17:21Z",
"dport": 80,
"sport": 54230,
"dip": "111.111.111.111",
"id": "xxx"
},
{
"origin": "sbbb",
"category": "bbb",
"confidence": "bbb",
"name": "bbb",
"proto": "tcp",
"address": [
{
"cc": "PL",
"ip": "222.222.222.222",
"asn": 000
}
],
"source": "aaa",
"time": "2020-02-25T07:17:11Z",
"dport": 80,
"sport": 44969,
"dip": "222.222.222.222",
"id": "xxx"
}</span>
<span style="font-size: 10pt">]</span>
For extracting IP addresses I use below command:
($JSON_file | ConvertFrom-Json | ForEach-Object address).ip | Out-File Only_IP_addresses.txt
And this command is working in PowerShell 7, but in PowerShell 6, and 5 it gives empty results… No errors, just empty results.
Any clue why is that?