Renamed to list-ip-addresses.ps1

This commit is contained in:
Markus Fleschutz 2024-06-18 20:22:51 +02:00
parent b218b25be1
commit 3eb68560d8
2 changed files with 26 additions and 4 deletions

View File

@ -16,10 +16,10 @@
#>
Write-Host "`n N E T W O R K" -foregroundColor green
& "$PSScriptRoot/list-ip-addresses.ps1"
& "$PSScriptRoot/ping-remote-hosts.ps1"
& "$PSScriptRoot/check-firewall"
& "$PSScriptRoot/check-dns.ps1"
& "$PSScriptRoot/check-vpn.ps1"
& "$PSScriptRoot/list-public-ip.ps1"
& "$PSScriptRoot/ping-local-hosts.ps1"
exit 0 # success

View File

@ -1,10 +1,10 @@
<#
.SYNOPSIS
Lists the public IP address
Lists the IP addresses
.DESCRIPTION
This PowerShell script queries the public IP address information and prints it.
This PowerShell script queries all IP address information and prints it.
.EXAMPLE
PS> ./list-public-ip.ps1
PS> ./list-ip-addresses.ps1
Public IP address 185.72.229.161, 2003:f2:6128:fd01:e543:601:30c2:a028 near Munich, Germany
.LINK
https://github.com/fleschutz/PowerShell
@ -12,7 +12,29 @@
Author: Markus Fleschutz | License: CC0
#>
function WriteLocalInterface($interface) {
$IPv4 = ""
$IPv6 = ""
$addresses = Get-NetIPAddress
foreach ($addr in $addresses) {
if ($addr.InterfaceAlias -like "$($interface)*") {
if ($addr.AddressFamily -eq "IPv4") {
$IPv4 = $addr.IPAddress
} else {
$IPv6 = $addr.IPAddress
}
}
}
if ($IPv4 -ne "" -or $IPv6 -ne "") {
Write-Host "✅ Local $interface IP address $IPv4, $IPv6"
}
}
try {
WriteLocalInterface "Ethernet"
WriteLocalInterface "WLAN"
WriteLocalInterface "Bluetooth"
if ($IsLinux) {
[string]$publicIPv4 = (curl -4 --silent ifconfig.co)
[string]$publicIPv6 = (curl -6 --silent ifconfig.co)