Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Parse a section from DNS backup file

$
0
0

Needed to parse out a section from a Windows DNS server zone-file backup.  Wanted to transform the section into a nicely structured table, containing the following record-columns:

  • Name
  • Class
  • Type,
  • Value
  • Comment

This is the quick "one-liner" script I came upwith.  It worked quite well so I though I'd share it.

 

Get-ChildItem \\Share\daily_zone_backup\bu2015-07-16 -Filter cravener.net.dns  |

 Get-Content |

  Select-String -Pattern 'john' |

  %{ $l = $_ -split ';';$r = (($l | Select-Object -First 1) -replace '\s+$', '') -replace '\s+', ','; $c = $l | Select-Object -Last 1; "$r,$c" }  |

   ConvertFrom-Csv -Header Name, Class, Type, Value, Comment  |

    Sort-Object -Property name |

     ft -AutoSize


Viewing all articles
Browse latest Browse all 6937

Trending Articles