Testing for SRV records - need help filtering hashtable results

This topic contains 1 reply, has 1 voice, and was last updated by  Mike Kanakos 3 weeks ago.

  • Author
  • #103439

    Mike Kanakos

    Need some help with the results of a hashtable...

    I am trying to query SRV records from DNS and confirm the number of records for each type. I have 29 domain controllers (all global Catalogs). I want to query DNS for each SRV record type (GC, DC, KDC) and confirm there are the same number of records and domain controllers. If not, send an email...

    $DCList = (get-adgroupmember "Domain Controllers").name
    $DCCount = (get-adgroupmember "Domain Controllers").count
    $PDCEmulator = (get-addomaincontroller -Discover -Service PrimaryDC).name
    $MSDCSZoneName = '_msdcs.bigfirm.biz'
    $ZoneName = 'bigfirm.biz'
    $DC_SRV_Record = '_ldap._tcp.dc'
    $GC_SRV_Record = '_ldap._tcp.gc'
    $KDC_SRV_Record = '_kerberos._tcp.dc'
    $PDC_SRV_Record = '_ldap._tcp.pdc' 
    $Results = @{}
    $Results.DCRecordCount = ((Get-DnsServerResourceRecord -ZoneName $MSDCSZoneName -Name $DC_SRV_Record  -RRType srv -ComputerName $PDCEmulator).count)
    $Results.GCRecordCount = ((Get-DnsServerResourceRecord -ZoneName $MSDCSZoneName -Name $GC_SRV_Record  -RRType srv -ComputerName $PDCEmulator).count)
    $Results.KDCRecordCount = ((Get-DnsServerResourceRecord -ZoneName $MSDCSZoneName -Name $KDC_SRV_Record  -RRType srv -ComputerName $PDCEmulator).count)

    The results that get saved to the $results hashtable.

    Name                           Value                                                                                                                                                        
    ----                           -----                                                                                                                                                        
    KDCRecordCount                 29                                                                                                                                                                                                                                                                                                               GCRecordCount                  29                                                                                                                                                           
    DCRecordCount                  29  

    If two of those values were less then 29, I would like to pull those out and email the records but i am not sure how to say, "give me all rows that do not equal $DCcount".

    Could someone point me in the right direction? if you have a better idea for my logic, I am open to ideas...

  • #103442

    Mike Kanakos

    Trying again... a row got cut off from my results table. it should have 3 rows:
    (KDCRecordCount 29, GCRecordCount 29, DCRecordCount29)

    Name                           Value                                                                                                                                                        
    ----                           -----                                                                                                                                                        
    KDCRecordCount                 29                                                                                                                                                           
    GCRecordCount                  29                                                                                                                                                           
    DCRecordCount                  29  

You must be logged in to reply to this topic.