Showing posts with label confused. Show all posts
Showing posts with label confused. Show all posts

Thursday, February 14, 2013

Powershell and DNS

Was trying to search for static address in a large subnet that I was working on.

start off with reading - http://gallery.technet.microsoft.com/scriptcenter/DNS-Server-PowerShell-afc2142b

retrieve the records with
$records = Get-DnsServerResourceRecord -ZoneName koolkids.internal -computer kcdc

tried
$records| ? recorddata -like "10.10.*"

got nothing returned... :(

then check the types:
$records | get-member
DistinguishedName         Property   string DistinguishedName {get;}
HostName                  Property   string HostName {get;}
PSComputerName            Property   string PSComputerName {get;}
RecordClass               Property   string RecordClass {get;}
RecordData                Property   CimInstance#Instance RecordData {get;set;}
RecordType                Property   string RecordType {get;}
Timestamp                 Property   CimInstance#DateTime Timestamp {get;}
TimeToLive                Property   CimInstance#DateTime TimeToLive {get;set;}

notice that is was CimInstance#Instance for the RecordData
can't remember how to convert it to string on the fly.
so my colleague suggested 
$records | out-gridview

then do the filtering from there, which work nice.

if after a few coffees I remember how to sort this out. I will update.