Skip to content

Instantly share code, notes, and snippets.

@Jaid
Created October 4, 2024 00:42

Revisions

  1. Jaid created this gist Oct 4, 2024.
    1 change: 1 addition & 0 deletions localIp.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    (Get-NetIPAddress -AddressFamily IPv4 -InterfaceIndex (Get-NetRoute -DestinationPrefix '0.0.0.0/0' | Where-Object { (Get-NetAdapter -InterfaceIndex $_.InterfaceIndex).InterfaceType -eq 6 } | Sort-Object Metric | Select-Object -First 1).InterfaceIndex | Where-Object { $_.IPAddress -notlike '127.*' }).IPAddress