Skip to content

Instantly share code, notes, and snippets.

@poshcodebear
Created July 31, 2015 05:45
Show Gist options
  • Save poshcodebear/64b647b08d4e55e12258 to your computer and use it in GitHub Desktop.
Save poshcodebear/64b647b08d4e55e12258 to your computer and use it in GitHub Desktop.
Simple Network Host Scan in PowerShell
$subnet = '192.168.1'
(1..254) | foreach {
$ip = "$subnet.$_"
$props = @{
'IP' = $ip ;
'Name' = (Resolve-DnsName $ip -ErrorAction SilentlyContinue | select -ExpandProperty NameHost) ;
'Response' = (Test-Connection $ip -Quiet -Count 1)
}
$obj = New-Object -TypeName psobject -Property $props
Write-Output $obj
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment