title: How to specify DNS server for a VPN Connection by PowerShell?
body: <p>I am fairly new to PowerShell so please forgive me if the question looks stupid.</p>
  
  <p>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 <code>VpnClient</code> module is capable. I figured that all the settings in "Networking" tab is not accessed by <code>VpnClient</code> module so I tried <code>DnsClient</code>, <code>NetAdapter</code>,<code>NetTCPIP</code> and <code>NetConnection</code>, but the commands in these module all need a parameter called either <code>Name</code> or <code>InterfaceAlias</code>. </p>
  
  <p>I successfully changed the DNS Configuration of my Ethernet Adapter by <code>Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses 8.8.8.8,8.8.4.4</code>. However, if I give my vpn name to <code>-InterfaceAlias</code> option then PowerShell gives out an error, saying it cannot find such InterfaceAlias. </p>
  
  <p>I listed all interfaces on my Windows but there's no sign of any vpn connection. 
  All helps are appreciated, thank you!</p>
  
  <hr>
  
  <p>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:</p>
  
  <pre><code>PS C:\WINDOWS\system32&gt; [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces().NetworkInterfaceType
  Wireless80211
  Wireless80211
  Ethernet
  Loopback
  Tunnel
  Tunnel
  </code></pre>
  
  <p>I haven't tried the second resolution which is "<strong>Use the GetAdaptersAddresses API</strong>" because I don't know how. Anyone knows? Or did I miss something from the .Net framework?</p>