2024-05-08 13:32:42 +02:00
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
2024-05-09 11:29:07 +02:00
|
|
|
|
Lists the (cached) network neighbors
|
2024-05-08 13:32:42 +02:00
|
|
|
|
.DESCRIPTION
|
|
|
|
|
This PowerShell script lists all cached network neighbors of the local computer.
|
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> ./list-network-neighbors.ps1
|
|
|
|
|
|
2024-05-08 18:56:05 +02:00
|
|
|
|
Name InterfaceAlias IPAddress LinkLayerAddress State
|
|
|
|
|
---- -------------- --------- ---------------- -----
|
|
|
|
|
<<>8:8:8<?;55;=55; Ethernet 224.0.0.251 01-00-5E-00-00-FB Permanent
|
2024-05-08 13:32:42 +02:00
|
|
|
|
...
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
try {
|
2024-05-09 11:29:07 +02:00
|
|
|
|
if ($IsLinux) {
|
|
|
|
|
& ip neigh
|
|
|
|
|
} elseif ($IsMacOS) {
|
|
|
|
|
& ip neigh
|
|
|
|
|
} else {
|
2024-05-09 11:41:56 +02:00
|
|
|
|
Get-NetNeighbor -includeAllCompartments | Format-Table -property @{e='IPAddress';width=38},@{e='InterfaceAlias';width=14},@{e='LinkLayerAddress';width=19},@{e='State';width=12}
|
2024-05-09 11:29:07 +02:00
|
|
|
|
}
|
2024-05-08 13:32:42 +02:00
|
|
|
|
exit 0 # success
|
|
|
|
|
} catch {
|
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|