SetDNSServerSearchOrder returns 70, Information from the MSDN is "invalid IP Address" for SetDNSServerSearchOrder
When I try with the IPv4 address it succeeds to add the DNS server. But when I try to give the IPv6 address instead of IPv4 address it doesn't work.
- Why it is not able to set the IPv6 address?
- What is the alternative for achiving this in IPv6 machine?
Below is the code snippet what I tried. Also tried giving IPAddress and string datatypes as the input to SetDNSServerSearchOrder.
PS C:\Users\Administrator> $NICs = Get-WmiObject Win32_NetworkAdapterConfiguration | Where {$_.IPEnabled -eq "TRUE" -and
($_.IPAddress -contains "1111:1111:1111:1111:1111:1111:1111:1114")}
PS C:\Users\Administrator> [System.Net.IPAddress]$IP="1111:1111:1111:1111:1111:1111:1111:1112"
PS C:\Users\Administrator> $IP
Address :
AddressFamily : InterNetworkV6
ScopeId : 0
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
IPAddressToString : 1111:1111:1111:1111:1111:1111:1111:1112
PS C:\Users\Administrator> $NICs.SetDNSServerSearchOrder($IP)
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 70
PS C:\Users\Administrator> [string]$IP="1111:1111:1111:1111:1111:1111:1111:1112"
PS C:\Users\Administrator> $NICs.SetDNSServerSearchOrder($IP)
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 70
PS C:\Users\Administrator> $IP
1111:1111:1111:1111:1111:1111:1111:1112
PS C:\Users\Administrator> $NICs
DHCPEnabled : True
IPAddress : {fe80::24b7:d14e:fd15:bd2b, 1111:1111:1111:1111:1111:1111:1111:1114}
DefaultIPGateway :
DNSDomain :
ServiceName : e1cexpress
Description : Intel(R) 82579LM Gigabit Network Connection
Index : 10
PS C:\Users\Administrator>
Below is the screenshot after running these commands.
Also searched in Google and can't find a solution. :-(
OS version: windows server 2008 r2
Powershell version: Powershell 2.0
Solution shall be unique so that I can use for both IPv4 and IPv6 systems.
It would be great if anyone can help in this regard.