There are lots of ways to do this, but I haven't found an elegant one that works well. Here is my approach that queries the registry:
You can change "$IPs.DhcpIPAddress" to "$IPs.IPAddress" if you have a static IP.
[array] $IPArray = @() $Adapters = Get-Childitem "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Adapters" foreach ($uid in $Adapters) { if ($uid.PSChildName -ne "NdisWanIp") { $Interface = "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" + $uid.PSChildName ## Write-Host "Checking: $Interface" $IPs = Get-ItemProperty $Interface $IPArray += $IPs.DhcpIPAddress } } $IPArray
You can change "$IPs.DhcpIPAddress" to "$IPs.IPAddress" if you have a static IP.
Comments
Post a Comment