<# # DNS_Record_Analyzer.ps1 # Creado por : Rodolfo Castro - Lync MVP # Version 1.0 # Fecha : 5.3.2015 # Revision de los DNS Internos para implementacion de Lync # Script que revisa que se tengan creados los registros # SRV : _sipInternaltls # A: Lyncdiscoverinternal # A: sipinternal # A: sip # A: Simple URLs # Para todos los dominios permitidos como SIPDomain en la topologia # # Control de Versiones # v1.0 : Creacion de script. # # # BLOG: HTTP://UCBLOG.MX # TWITTER : @UCBLOGMX # FACEBOOK.COM/UCBLOGMX #> Import-Module Lync Import-Module ActiveDirectory $hostname = hostname Function Get-DnsEntry($iphost) { If($ipHost -match "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$") { [System.Net.Dns]::GetHostEntry($iphost).HostName } ElseIf( $ipHost -match "^.*\.\.*") { [System.Net.Dns]::GetHostEntry($iphost).AddressList[0].IPAddressToString } ELSE { Throw "Especificar una direccion IPv4 o un hostname" } } #end Get-DnsEntry #creando carpeta diaria $date = Get-Date -format yyyy_MM_dd_hh_mm $filepath = ".\Reporte_DNS_" + $date New-Item $filepath -type directory -force |out-null $file = $filepath + "\DNS_" + $date + ".htm" "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append '.: REPORTE DNS :. ' | Out-File $file -append '" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "
" | Out-File $file -append " REPORTE DE DNS " | Out-File $file -append "
" | Out-File $file -append ##REGISTROS SRV $SIPDomainList = Get-CsSipDomain foreach ( $sipdomain in $SIPDomainList){ $sipsrvint = "_sipInternaltls._tcp." $sipdomainName = $sipdomain.Name $dnscheck2 = $sipsrvint + $sipdomain.Name $dnscmd = "nslookup -type=srv " + $dnscheck2 $dnsresults = Invoke-Expression $dnscmd $sipAhost = $dnsresults.SyncRoot[9] $sipaport = $dnsresults.syncroot[8] $siphost = $sipAhost.Split("=") $sipport = $sipaport.Split("=") $dnscheckhost = $siphost[1].trim() $dnscheckport = $sipport[1].trim() "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append #> ##REGISTROS A $lyncdcover = "lyncdiscoverinternal." + $sipdomain.Name $LyncDvrInt = Get-DnsEntry $lyncdcover $SipdnsA = "sip." + $sipdomain.Name $SipdnsE = Get-DnsEntry $sipdnsA $sipintdnsA= "sipinternal." + $sipdomain.Name $sipintdnsE = Get-DnsEntry $sipintdnsA "
" | Out-File $file -append ".: Dominio $sipdomainName :. " | Out-File $file -append "
SRV HostName Port
$dnscheck2 $dnscheckhost $dnscheckport
" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append if($LyncDvrInt) {"" | Out-File $file -append } else{ "" | Out-File $file -append } "" | Out-File $file -append if($sipdnsE) {"" | Out-File $file -append } else{ "" | Out-File $file -append } "" | Out-File $file -append if($sipintdnsE) {"" | Out-File $file -append } else{ "" | Out-File $file -append } } $simpleURL = Get-CsSimpleUrlconfiguration | Select-Object -ExpandProperty SimpleURL "" | Out-File $file -append "" | Out-File $file -append "" | Out-File $file -append foreach ($url in $simpleURL){ $urlsplit = $url -split "//" $urlfinal = $urlsplit[1] $urldns = Get-DnsEntry $urlfinal "" | Out-File $file -append if($urldns) {"" | Out-File $file -append } else{ "" | Out-File $file -append } }
" | Out-File $file -append " .: Registro A :. " | Out-File $file -append "
FQDN IP
$lyncdcover $LyncDvrInt
NO EXISTE REGISTRO
$sipdnsA $sipdnsE
NO EXISTE REGISTRO
$sipintdnsA $sipintdnsE
NO EXISTE REGISTRO
" | Out-File $file -append " .: SIMPLE URLs :. " | Out-File $file -append "
$urlfinal $urldns
NO EXISTE REGISTRO