0

I'm writing a Powershell script and am querying the local DNS resource for both CNAME and A records matching specific criteria (specifically against HP servers). Using full administrator access rights using WQL against the root\MicrosoftDNS provider, I was presented with 0 records for the following:

select * from MicrosoftDNS_ResourceRecord where TextRepresentation like '%sql%'

However, negating a negation works.

select * from MicrosoftDNS_ResourceRecord where NOT(NOT(TextRepresentation like '%sql%'))

Why? Am I going insane?

The full query is:

select * from MicrosoftDNS_ResourceRecord where NOT (ContainerName like '..%' OR OwnerName like '%ilo%') AND (__CLASS = 'MicrosoftDNS_AType' OR __CLASS = 'MicrosoftDNS_CNAMEType') AND NOT(NOT(TextRepresentation like '%sql%'))
Dan
  • 106
  • 4
  • Just a hunch but do the records that get pulled back have `NULL` for `TextRepresentation`? – Patrick87 Oct 09 '15 at 16:16
  • Unfortunately, while testing under wbemtest, I receive a 0x80041001 (Generic failure) error message for: select * from MicrosoftDNS_ResourceRecord where TextRepresentation IS NULL – Dan Oct 09 '15 at 19:05
  • What about the records you get from your full query? I mean your queries are pulling back records right? What are their fields like? – Patrick87 Oct 09 '15 at 20:22
  • Yes, records are received as intended (~1000 records against production), as if the double negatives were not put in. I have further tested it by installing DNS service on a new server with only one zone with an A and a CNAME record. The fields are what a normal WQL query would return like in either case in wbemtest. Example: instance of MicrosoftDNS_AType { ContainerName = "xxx"; DnsServerName = "xxx"; DomainName = "xxx"; IPAddress = "1.2.3.4"; OwnerName = "xxx"; RecordClass = 1; RecordData = "1.2.3.4"; TextRepresentation = "xxx IN A 1.2.3.4"; Timestamp = 0; TTL = 900; }; – Dan Oct 10 '15 at 19:32

0 Answers0