I have read through a listing of all the DNS powershell cmdlets and can't believe I didn't find a programmatic way of reading the below list. Am I missing it, or is there a .NET way to do so that I didn't also find?
Asked
Active
Viewed 2,545 times
3
-
1Does this answer your question? [Powershell Get-DnsServerResourceRecord seemingly returning all name servers in every zone, not just for the one specified](https://serverfault.com/questions/1012326/powershell-get-dnsserverresourcerecord-seemingly-returning-all-name-servers-in-e) – Sorean Apr 17 '20 at 04:59
-
@Sorean - Not sure if it was realised, but both your linked to question and this one are mine, but different. It seems what is in the above box is not linked to the name servers in the zone. – user66001 Apr 17 '20 at 05:37
-
Yes I am aware, but you are asking the same question in both questions. You're looking for a Powershell to get the data in your screenshot. That or you need to adjust your questions. – Sorean Apr 17 '20 at 06:32
-
@Sorean - I thought the other question was the problem, but now realise that the other question is not the correct understanding of the problem. They are different because the Get-DnsServerResourceRecord only gets DNS records (what clients use to facilitate DNS requests), not what the above dialog box has in it (replication of DNS records, which is handled by the DNS server(s) and not the clients wanting DNS info). – user66001 Apr 17 '20 at 13:49
-
@Sorean If the other question gets answered it will help people who think like me initially (If we are fixated on that Q, and not this one, will answer the other Q myself). This question is my current problem. – user66001 Apr 17 '20 at 13:51
2 Answers
0
Get-DnsServerResourceRecord -ComputerName <DNS Server You Are Querying> -ZoneName <Forward Lookup Zone Name> -RRType NS
The name serves type in the properties of the domain you are looking at are populated in the forward lookup zone as NS name records. Those are the name servers for that domain. Querying for the NS resource record in the PS command above will give you those records. To change them, you would use the Set-DnsServerResourceRecord
cmdlet.
The DNS Server cmdlets are located in the DNSServer powershell module.
You can import that commandlet with Import-Module -Name DNSServer
cmd.
You can look at all the commands associated with that module by typing get-command -Module DNSServer
command.
![](../../users/profiles/266067.webp)
Citizen
- 1,103
- 1
- 10
- 19
-
Thanks for your answer and info on how to find other DNS cmdlets, but alas that command is what I ran initially that didn't return what was in the screenshot dialog on this question. See https://serverfault.com/questions/1012326/powershell-get-dnsserverresourcerecord-seemingly-returning-all-name-servers-in-e for what it did, if helpful. – user66001 Apr 24 '20 at 08:59
0
`#
# Import the required PowerShell modules
#
Import-Module DNSServer -ErrorAction Ignore
if (-not (Get-Module DNSServer)) {
throw 'The Windows Feature "DNS Server Tools" is not installed. `
(On server SKU run "Install-WindowsFeature -Name RSAT-DNS-Server", on client SKU install RSAT client)
}
Get-DnsServerResourceRecord -ZoneName "contoso.com" -RRType "NS" -Node
![](../../users/profiles/971671.webp)
Ace
- 419
- 6
-
Sorry, how is this different from the other answer already provided? – user66001 Sep 06 '22 at 07:19