none
IPv6 DNS configuration RRS feed

  • Question

  • Hi,

    i want configure my IPV6 DNS entries with a script.

    The script is generally working. The only probolem i am having is, that the command is not accepting a variable and i do not knwo why.

    If I add the content of the variable manually then its working.

    Working:

    set-DnsClientServerAddress -InterfaceIndex 4 -ServerAddresses ("2a01:a080:1e0:1920:26aa:8871:ddc0:cc9e","2a01:a080:1e0:1920:5aa1:d260:ba56:3240")

    Not working:

    set-DnsClientServerAddress -InterfaceIndex 4 -ServerAddresses ($variable)

    The type of the varaibale is STRING.

    You can see the error in the picture.

    Tuesday, July 16, 2019 6:16 AM

All replies

  • It has to be an array:

    $dnsAddresses = @(
        '2a01:a080:1e0:1920:26aa:8871:ddc0:cc9e', 
        '2a01:a080:1e0:1920:5aa1:d260:ba56:3240'
    )
    Set-DnsClientServerAddress -InterfaceIndex 4 -ServerAddresses $dnsAddresses


    \_(ツ)_/

    Tuesday, July 16, 2019 6:21 AM
  • You can also do it like this:

    [string[]]$dnsAddresses = '2a01:a080:1e0:1920:26aa:8871:ddc0:cc9e','2a01:a080:1e0:1920:5aa1:d260:ba56:3240'
    


    \_(ツ)_/

    Tuesday, July 16, 2019 6:24 AM
  • It has to be an array:

    $dnsAddresses = @(
        '2a01:a080:1e0:1920:26aa:8871:ddc0:cc9e', 
        '2a01:a080:1e0:1920:5aa1:d260:ba56:3240'
    )
    Set-DnsClientServerAddress -InterfaceIndex 4 -ServerAddresses $dnsAddresses


    \_(ツ)_/

    Thanks this is working.

    My DNS adresses are stored in a variable. Each DNS adress is a spearte Object. Are you having an idea how to transfer the objects to one array?

    Tuesday, July 16, 2019 8:46 AM