PoshCode Logo PowerShell Code Repository

Get-PrimaryIPAddress by halr9000 28 months ago
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1403"></script>download | new post

As seen on http://halr9000.com/article/829#comments. Needs some prettying up with help and stuff but should work well.

  1. [system.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() |
  2.         Where-Object { $_.GetIPProperties().GatewayAddresses } |
  3.                 ForEach-Object {
  4.                         $_.GetIPProperties().UnicastAddresses| ForEach-Object {
  5.                                 $_.Address.IPAddressToString
  6.                         }
  7.                 }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me