I am fairly new to PowerShell so please forgive me if the question looks stupid.
I am trying to configure VPN Connections using PowerShell. With the help of PowerShell ISE, I have no trouble creating a VPN connection and configuring VPN specifics. However I also need to set the DNS server of this VPN to 8.8.8.8, a task of which none of the cmdlets in VpnClient
module is capable. I figured that all the settings in "Networking" tab is not accessed by VpnClient
module so I tried DnsClient
, NetAdapter
,NetTCPIP
and NetConnection
, but the commands in these module all need a parameter called either Name
or InterfaceAlias
.
I successfully changed the DNS Configuration of my Ethernet Adapter by Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses 8.8.8.8,8.8.4.4
. However, if I give my vpn name to -InterfaceAlias
option then PowerShell gives out an error, saying it cannot find such InterfaceAlias.
I listed all interfaces on my Windows but there's no sign of any vpn connection. All helps are appreciated, thank you!
Thanks to @DavidBrabant, it seems that it is a bug that Microsoft has not fixed since Windows Vista. I then followed one of the solutions on that kb article: using .Net Class. The result is still the same as before: no sign of any vpn connection. My input and output look like this:
PS C:\WINDOWS\system32> [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces().NetworkInterfaceType
Wireless80211
Wireless80211
Ethernet
Loopback
Tunnel
Tunnel
I haven't tried the second resolution which is "Use the GetAdaptersAddresses API" because I don't know how. Anyone knows? Or did I miss something from the .Net framework?