quinta-feira, 26 de setembro de 2019

Powershell - DNS

DNS Record Permission

$DomainName = "domain.com" #(Get-ADDomain).Forest

#Partition options
$AdDnsPartition = "DC=DomainDnsZones" #Scope: To all DNS servers in this domain
$AdDnsPartition = "DC=ForestDnsZones" #Scope: To all DNS servers in this forest
$AdDnsPartition = "CN=System" #Scope: To all domain controllers in this domain (for Windows 2000 compatibility)

$Hostname = "PC1234"

$Path = "AD:\DC=$DomainName,CN=MicrosoftDNS,$AdDnsPartition,DC=$($DomainName.Split('.') -join ',DC=')"

$Record = Get-ChildItem -Path $Path |Where {$_.name -like "*$Hostname*"}
(Get-Acl -Path "ActiveDirectory:://RootDSE/$($Record.DistinguishedName)").Access | Where {$_.IdentityReference -like "*$Hostname*"}


Get DNS Record

$DNSServer = "10.0.0.1"
$Zone = "domain.com"
$Record = "PC1234"
$NodeDNS = Get-DnsServerResourceRecord -ComputerName $DNSServer -ZoneName $Zone -Name $Record


Get DNS Record in DNS Servers

$DNSServerList = "10.0.0.1","10.0.0.2","10.0.0.3","10.0.0.4"
foreach ($DNSServer in $DNSServerList){
    Write-Host "DNS Server: $DNSServer"
    Get-DnsServerResourceRecord -ComputerName $DNSServer -ZoneName $Zone -Name $Record
}


Zone List

$ZoneList = "child1.domain.com","child2.domain.com","child3.domain.com"
foreach ($Zone in $ZoneList){
    Get-DnsServerResourceRecord -ComputerName $DNSServer -ZoneName $Zone -Name $Record
}

References:
http://clintboessen.blogspot.com/2010/02/active-directory-dns-zone-locations.html
https://gallery.technet.microsoft.com/scriptcenter/Get-Active-Directory-DNS-8c2fe077

Nenhum comentário:

Postar um comentário