title: Powershell cmdlet that returns an object containing default gateway for interface
body: <p>I have searched up and down Microsoft's documentation for a cmdlet that returns an object containing the default gateway for an interface. I know Get-NetIPConfiguration returns the default gateway however, it does not return an object for me to use. Any ideas? </p>
  
  <p>Edit here is what i am running. I am trying to automatically change a nic's ip address and for that i need the default gateway of the nic.</p>
  
  <pre><code>$ip =  Get-NetIPConfiguration -InterfaceIndex 17
  New-NetIPAddress -IPAddress (New Ip address) -PrefixLength (Current Prefix length) -DefaultGateway $ip.IPv4DefaultGateway
  </code></pre>