Created
May 17, 2024 01:45
-
-
Save ShortArrow/020e9408fb79d138961152d74b13190b to your computer and use it in GitHub Desktop.
Revisions
-
ShortArrow created this gist
May 17, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ $network = "192.168.." 1..254 | ForEach-Object { $ip = $network + $_ $ping = Test-Connection -ComputerName $ip -Count 1 -Quiet if ($ping) { try { $hostname = ([System.Net.Dns]::GetHostByAddress($ip)).HostName } catch { $hostname = $_.Exception.Message } Write-Output "$ip - $hostname" } }