How to select specified value from resolve-dnsname result?

Daniel Sajdyk 41 Reputation points
2021-03-11T07:53:02.743+00:00

Hello
I have domain with multiple domain controllers.

When I use:
Resolve-dnsname "my_domain"
I got result with type Selected.Microsoft.DnsClient.Commands.DnsRecord_A contains all of them.

No I want to select ony specified controllers from this list - for example I want controller which is second and fifth on that list.

How can I do that?

Best Regards
Daniel

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,460 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 34,271 Reputation points Microsoft Vendor
    2021-03-11T09:05:50.557+00:00

    Hi @Daniel Sajdyk ,

    To select the specified items you can try something like this

    $records = Resolve-dnsname "my_domain"  
    $selected = $records[1], $records[4]  
    $selected  
    

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Daniel Sajdyk 41 Reputation points
    2021-03-11T09:23:15.65+00:00

    Great :) Thank you :)

    0 comments No comments