mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-23 08:23:14 +01:00
Added list-local-ip.ps1
This commit is contained in:
parent
305077d5cd
commit
ace08b19c6
@ -1,5 +1,5 @@
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
a.root-servers.net,
|
abc.com
|
||||||
airbnb.com,
|
airbnb.com,
|
||||||
aka.ms,
|
aka.ms,
|
||||||
api.met.no,
|
api.met.no,
|
||||||
@ -10,8 +10,8 @@ amazon.com,
|
|||||||
b.root-servers.net,
|
b.root-servers.net,
|
||||||
bing.com,
|
bing.com,
|
||||||
bitbucket.org,
|
bitbucket.org,
|
||||||
c.root-servers.net,
|
|
||||||
client.dropbox.com,
|
client.dropbox.com,
|
||||||
|
cnn.com,
|
||||||
contacts.google.com,
|
contacts.google.com,
|
||||||
d.dropbox.com,
|
d.dropbox.com,
|
||||||
d.root-servers.net,
|
d.root-servers.net,
|
||||||
@ -98,4 +98,4 @@ www.whatsapp.com,
|
|||||||
www.whitehouse.gov,
|
www.whitehouse.gov,
|
||||||
www.windy.com,
|
www.windy.com,
|
||||||
www.wikipedia.org,
|
www.wikipedia.org,
|
||||||
www.youtube.com,
|
www.youtube.com,
|
|
@ -2,10 +2,10 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Check the DNS resolution
|
Check the DNS resolution
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script measures the DNS resolution speed (using 100 popular domains) and prints it.
|
This PowerShell script measures the DNS resolution speed using 100 internet domains and prints it.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./check-dns.ps1
|
PS> ./check-dns.ps1
|
||||||
✅ DNS resolves 56.5 domains per second
|
✅ Internet DNS resolves 56.5 domains/sec
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,24 +13,22 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
#Write-Progress "Measuring DNS resolution..."
|
|
||||||
$table = Import-CSV "$PSScriptRoot/../data/popular-domains.csv"
|
$table = Import-CSV "$PSScriptRoot/../data/popular-domains.csv"
|
||||||
$numRows = $table.Length
|
|
||||||
|
|
||||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
foreach($row in $table){$nop=dig $row.Domain +short}
|
foreach($row in $table){$nop=dig $row.Domain +short}
|
||||||
} else {
|
} else {
|
||||||
|
Clear-DnsClientCache
|
||||||
foreach($row in $table){$nop=Resolve-DNSName $row.Domain}
|
foreach($row in $table){$nop=Resolve-DNSName $row.Domain}
|
||||||
}
|
}
|
||||||
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||||
|
|
||||||
#Write-Progress -completed "Measuring DNS resolution..."
|
$speed = [math]::round($table.Length / $elapsed, 1)
|
||||||
$average = [math]::round($numRows / $elapsed, 1)
|
if ($speed -lt 10.0) {
|
||||||
if ($average -lt 10.0) {
|
Write-Host "⚠️ Internet DNS resolves $speed domains/sec only"
|
||||||
Write-Host "⚠️ DNS resolves $average domains per second only"
|
|
||||||
} else {
|
} else {
|
||||||
Write-Host "✅ DNS resolves $average domains per second"
|
Write-Host "✅ Internet DNS resolves $speed domains/sec"
|
||||||
}
|
}
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Checks the network details
|
Checks the network
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script queries the network details of the local computer and prints it.
|
This PowerShell script queries the network details of the local computer and prints it.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./check-network.ps1
|
PS> ./check-network.ps1
|
||||||
|
|
||||||
N E T W O R K
|
N E T W O R K
|
||||||
✅ Online with 30ms latency (16ms..56ms, 0/10 loss)
|
✅ Firewall enabled
|
||||||
...
|
...
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -17,10 +17,11 @@
|
|||||||
|
|
||||||
Write-Host "`n N E T W O R K" -foregroundColor green
|
Write-Host "`n N E T W O R K" -foregroundColor green
|
||||||
& "$PSScriptRoot/check-firewall"
|
& "$PSScriptRoot/check-firewall"
|
||||||
& "$PSScriptRoot/list-ip-addresses.ps1"
|
& "$PSScriptRoot/list-local-ip.ps1"
|
||||||
& "$PSScriptRoot/ping-local-devices.ps1"
|
& "$PSScriptRoot/ping-local-devices.ps1"
|
||||||
& "$PSScriptRoot/list-ssh-key.ps1"
|
& "$PSScriptRoot/check-vpn.ps1"
|
||||||
|
& "$PSScriptRoot/list-internet-ip.ps1"
|
||||||
& "$PSScriptRoot/ping-remote-hosts.ps1"
|
& "$PSScriptRoot/ping-remote-hosts.ps1"
|
||||||
& "$PSScriptRoot/check-dns.ps1"
|
& "$PSScriptRoot/check-dns.ps1"
|
||||||
& "$PSScriptRoot/check-vpn.ps1"
|
& "$PSScriptRoot/list-ssh-key.ps1"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
This PowerShell script clears the DNS client cache of the local computer.
|
This PowerShell script clears the DNS client cache of the local computer.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./clear-dns-cache.ps1
|
PS> ./clear-dns-cache.ps1
|
||||||
✅ Cleared DNS cache in 1 sec
|
✅ Cleared DNS cache in 1s.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
|
||||||
Clear-DnsClientCache
|
Clear-DnsClientCache
|
||||||
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||||
"✅ Cleared DNS cache in $Elapsed sec"
|
"✅ Cleared DNS cache in $($elapsed)s."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Lists the IP addresses
|
Lists the Internet IP address
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script queries all IP address information and prints it.
|
This PowerShell script queries all public IP address information and prints it.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-ip-addresses.ps1
|
PS> ./list-internet-ip.ps1
|
||||||
✅ Internet IP 185.72.229.161, 2003:f2:6128:fd01:e543:601:30c2:a028 near Munich, Germany
|
✅ Internet IP 185.72.229.161, 2003:f2:6128:fd01:e543:601:30c2:a028 near Munich, Germany
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -12,24 +12,6 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
function WriteLocalInterface($interface) {
|
|
||||||
$IPv4 = $IPv6 = $prefixLen = ""
|
|
||||||
$addresses = Get-NetIPAddress
|
|
||||||
foreach ($addr in $addresses) {
|
|
||||||
if ($addr.InterfaceAlias -like "$($interface)*") {
|
|
||||||
if ($addr.AddressFamily -eq "IPv4") {
|
|
||||||
$IPv4 = $addr.IPAddress
|
|
||||||
$prefixLen = $addr.PrefixLength
|
|
||||||
} else {
|
|
||||||
$IPv6 = $addr.IPAddress
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($IPv4 -ne "" -or $IPv6 -ne "") {
|
|
||||||
"✅ Local $interface IP $IPv4/$prefixLen, $IPv6"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
[string]$publicIPv4 = (curl -4 --silent ifconfig.co)
|
[string]$publicIPv4 = (curl -4 --silent ifconfig.co)
|
||||||
@ -37,9 +19,6 @@ try {
|
|||||||
[string]$city = (curl --silent ifconfig.co/city)
|
[string]$city = (curl --silent ifconfig.co/city)
|
||||||
[string]$country = (curl --silent ifconfig.co/country)
|
[string]$country = (curl --silent ifconfig.co/country)
|
||||||
} else {
|
} else {
|
||||||
WriteLocalInterface "Ethernet"
|
|
||||||
WriteLocalInterface "WLAN"
|
|
||||||
WriteLocalInterface "Bluetooth"
|
|
||||||
[string]$publicIPv4 = (curl.exe -4 --silent ifconfig.co)
|
[string]$publicIPv4 = (curl.exe -4 --silent ifconfig.co)
|
||||||
[string]$publicIPv6 = (curl.exe -6 --silent ifconfig.co)
|
[string]$publicIPv6 = (curl.exe -6 --silent ifconfig.co)
|
||||||
[string]$city = (curl.exe --silent ifconfig.co/city)
|
[string]$city = (curl.exe --silent ifconfig.co/city)
|
43
scripts/list-local-ip.ps1
Normal file
43
scripts/list-local-ip.ps1
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
List local IP addresses
|
||||||
|
.DESCRIPTION
|
||||||
|
This PowerShell script queries all local IP address information and prints it.
|
||||||
|
.EXAMPLE
|
||||||
|
PS> ./list-local-ip.ps1
|
||||||
|
✅ Local Ethernet IP 192.168.178.21/24, 2003:f2:670b:e700:31e5:de86:b7cd:4e45
|
||||||
|
.LINK
|
||||||
|
https://github.com/fleschutz/PowerShell
|
||||||
|
.NOTES
|
||||||
|
Author: Markus Fleschutz | License: CC0
|
||||||
|
#>
|
||||||
|
|
||||||
|
function WriteLocalInterface($interface) {
|
||||||
|
$IPv4 = $IPv6 = $prefixLen = ""
|
||||||
|
$addresses = Get-NetIPAddress
|
||||||
|
foreach ($addr in $addresses) {
|
||||||
|
if ($addr.InterfaceAlias -like "$($interface)*") {
|
||||||
|
if ($addr.AddressFamily -eq "IPv4") {
|
||||||
|
$IPv4 = $addr.IPAddress
|
||||||
|
$prefixLen = $addr.PrefixLength
|
||||||
|
} else {
|
||||||
|
$IPv6 = $addr.IPAddress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($IPv4 -ne "" -or $IPv6 -ne "") {
|
||||||
|
"✅ Local $interface IP $IPv4/$prefixLen, $IPv6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($IsLinux) { exit 0 }
|
||||||
|
|
||||||
|
WriteLocalInterface "Ethernet"
|
||||||
|
WriteLocalInterface "WLAN"
|
||||||
|
WriteLocalInterface "Bluetooth"
|
||||||
|
exit 0 # success
|
||||||
|
} catch {
|
||||||
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
exit 1
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
Specifies the hosts to ping, seperated by commata (10 Internet servers by default)
|
Specifies the hosts to ping, seperated by commata (10 Internet servers by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./ping-remote-hosts.ps1
|
PS> ./ping-remote-hosts.ps1
|
||||||
✅ Online with 11...40ms latency - 18ms average
|
✅ Internet latency 12ms (9...18ms range)
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -36,7 +36,7 @@ try {
|
|||||||
Write-Host "⚠️ Internet offline (100% ping loss)"
|
Write-Host "⚠️ Internet offline (100% ping loss)"
|
||||||
} elseif ($loss -eq 0) {
|
} elseif ($loss -eq 0) {
|
||||||
$avg /= $success
|
$avg /= $success
|
||||||
Write-Host "✅ Internet latency $($min)...$($max)ms, average is $($avg)ms"
|
Write-Host "✅ Internet latency $($avg)ms ($($min)...$($max)ms range)"
|
||||||
} else {
|
} else {
|
||||||
$avg /= $success
|
$avg /= $success
|
||||||
Write-Host "✅ Online with $loss/$total ping loss and $($min)...$($max)ms latency - $($avg)ms average"
|
Write-Host "✅ Online with $loss/$total ping loss and $($min)...$($max)ms latency - $($avg)ms average"
|
||||||
|
Loading…
Reference in New Issue
Block a user