Powershell commands for DNS Management
Get DNS Record
Remove All Root Hints
Get-DnsServerResourceRecord -ZoneName "..roothints" | Remove-DnsServerResourceRecord -Force -ZoneName "..roothints"
Remove A Record
Remove-DnsServerResourceRecord -ZoneName "MyZone" -RRType "A" -Name "Host01" -RecordData "10.10.3.11"
Add-DnsServerResourceRecordCName -ComputerName DNSSrvr01 -ZoneName 'Myzone' -Name MyHostname -HostNameAlias MyHostnameAlias
Remove C-Name
Remove-DnsServerResourceRecord -ZoneName 'Myzone.com' -ComputerName DnSSrvr001 -RRType CName -Name "MyCname" -Force
Where
Remove All Root Hints
Get-DnsServerResourceRecord -ZoneName "..roothints" | Remove-DnsServerResourceRecord -Force -ZoneName "..roothints"
Remove A Record
Remove-DnsServerResourceRecord -ZoneName "MyZone" -RRType "A" -Name "Host01" -RecordData "10.10.3.11"
Search C-Name
Get-DnsServerResourceRecord -RRType CName -ZoneName "contoso.com" | ? {$_.RecordData.HostNameAlias -eq "hostname.contoso.com." -and $_.HostName -eq "web1.yourdomain.com"
Add C-Name
Get-DnsServerResourceRecord -RRType CName -ZoneName "contoso.com" | ? {$_.RecordData.HostNameAlias -eq "hostname.contoso.com." -and $_.HostName -eq "web1.yourdomain.com"
Add C-Name
Remove C-Name
Remove-DnsServerResourceRecord
Where
- MyZone is the zone name
- ComputerName is the DNS Server to which you want to connect. Ignore this switch if you are running from the same server
Comments
Post a Comment