Hi,
I'm working on a project trying to parse the contents of the zones and records, which I will be using for some other task in my project.
I'm using the below command to get the data in the json format on windows server 2019.
For zones:
Get-DnsServerZone|ConvertTo-Json
Get-DnsServerResourceRecord -ZoneName test.com -RRtype 'SOA'|ConvertTo-Json
For records:
Get-DnsServerResourceRecord -ZoneName test.com|ConvertTo-Json
For the zones, I mainly extract values such as zonename, ttl, expiry etc. and for the records, I mainly extract the record values such as ip addr etc
Note: I'm using python to parse the json data
The command works fine for small amount of data, but when I try to extract info of a zone which consists of thousands(or maybe a million, I'm not sure of the exact count) of records, the commands gets stuck (I have waited for around 15 hours after executing the command). Also, once I encountered the below issue.
ConvertTo-Json : Exception of type 'System.OutOfMemoryException' was thrown.
At line:1 char:61
- ... nsServerResourceRecord -ZoneName test.com|ConvertTo-Json
- ~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [ConvertTo-Json], OutOfMemoryException
- FullyQualifiedErrorId : System.OutOfMemoryException,Microsoft.PowerShell.Commands.ConvertToJsonCommand
What would be the best way to get the required data in the json format, for such huge data set? Also, please let me know if there are any other viable methods to accomplish this. I would like the final output to be in json format as its easy to parse.