mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-28 17:48:59 +01:00
Updated list-ip-addresses.ps1
This commit is contained in:
parent
b5ff7b0a6c
commit
bbb0a590cf
@ -13,20 +13,20 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
function WriteLocalInterface($interface) {
|
function WriteLocalInterface($interface) {
|
||||||
$IPv4 = ""
|
$IPv4 = $IPv6 = $prefixLen = ""
|
||||||
$IPv6 = ""
|
|
||||||
$addresses = Get-NetIPAddress
|
$addresses = Get-NetIPAddress
|
||||||
foreach ($addr in $addresses) {
|
foreach ($addr in $addresses) {
|
||||||
if ($addr.InterfaceAlias -like "$($interface)*") {
|
if ($addr.InterfaceAlias -like "$($interface)*") {
|
||||||
if ($addr.AddressFamily -eq "IPv4") {
|
if ($addr.AddressFamily -eq "IPv4") {
|
||||||
$IPv4 = $addr.IPAddress
|
$IPv4 = $addr.IPAddress
|
||||||
|
$prefixLen = $addr.PrefixLength
|
||||||
} else {
|
} else {
|
||||||
$IPv6 = $addr.IPAddress
|
$IPv6 = $addr.IPAddress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($IPv4 -ne "" -or $IPv6 -ne "") {
|
if ($IPv4 -ne "" -or $IPv6 -ne "") {
|
||||||
Write-Host "✅ Local $interface IP address $IPv4, $IPv6"
|
Write-Host "✅ Local $interface IP address $IPv4/$prefixLen, $IPv6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user