Get DNS records

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Get DNS records

Post by apowershelluser »

So going back

(Get-WmiObject Win32_NetworkAdapterConfiguration -FIlter 'IPEnabled=True').DNSDomainSuffixSearchOrder

Only one of my adapters had an IP

It still returned duplicates

I just want all of my 20+ DNSs in a variable to use
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Get DNS records

Post by jvierra »

If you do this:

Get-WmiObject Win32_NetworkAdapterConfiguration -FIlter 'IPEnabled=True'

What do you see?
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Get DNS records

Post by apowershelluser »

DNS2.png
DNS2.png (27.05 KiB) Viewed 2667 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Get DNS records

Post by jvierra »

What does this show:

Get-WmiObject Win32_NetworkAdapterConfiguration -FIlter 'IPEnabled=True'| select name,DNSDomainSuffixSearchOrder
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Get DNS records

Post by apowershelluser »

I did forget to add, it showed one under DNSDomain

This appears duplicates
Snag_5c52f2.png
Snag_5c52f2.png (12.7 KiB) Viewed 2629 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Get DNS records

Post by jvierra »

You are returning two adapters. That will give you duplicates. You can only expand arrays on one adapter to get only that adapters settings.
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Get DNS records

Post by apowershelluser »

This finally gives me one
Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {($_.IPEnabled -eq $true) -and ($_.DHCPEnabled -eq $true)} | select name,DNSDomainSuffixSearchOrder

There is also a VM adapter enabled, BUT it doesn't have any DNSDomains attached to it..

Regardless, I'm picking up what you're putting down.
This topic is 5 years and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked