Come fare per pingare un range di indirizzi senza installare alcun programma di ip scanning? Semplice con Powershell.
Soluzione veloce con linea di comando
Ad esempio per pingare da 192.168.1.1 a 192.168.1.20:
1..20|ForEach-Object -process {ping -n 1 192.168.1.$_}|Select-String “TTL”
Oppure soluzione completa con questo script:
$ErrorActionPreference = "SilentlyContinue" [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $testnull=$null if ($args[0]) {} else { write-host "" write-host "MANCANZA PARAMETRI:" write-host "------------------" write-host "Digitare il file .ps1 seguito dalla classe di IP e dal primo e l’ultimo host" write-host "Esempio: file.ps1 192.168.1 1 255 per pingare da 192.168.1.1 192.168.1.255" write-host "" break } $ping = New-Object System.Net.NetworkInformation.Ping $i = 0 $Lista="LISTA IP PINGABILI DA " + $args[0] +"." +$args[1] +" a " +$args[2] +"`n" + "`n" + "IP Pingabili" + "`n" + "————————" + "`n" $Classe=$args[0] $Range=$args[1]..$args[2] $Descrizione="Esecuzione ping da " + $args[0] + "." + $args[1] + " a " +$args[0] + "." + $args[2] Write-Host $Descrizione $Range | foreach { $ip ="$Classe.$_" $Res = $ping.send($ip) if ($Res.Status -eq "Success") { $result = $ip +" = Success" $hostIP = ([System.Net.Dns]::GetHostByAddress("$ip")).HostName > $null $Lista=$Lista + $i +") " + $ip + " – " + $HostIp + "`n" $i++ } } $Hosts = [string]$i +" Hosts is pingable" cls Write-host $Lista $altezzaform=30*$i+150 $objForm = New-Object System.Windows.Forms.Form $objForm.Text ="Data Entry Form" $objForm.Size = New-Object System.Drawing.Size(300,$altezzaform) $objForm.StartPosition ="CenterScreen" $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$x=$objTextBox.Text;$objForm.Close()}}) $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(105,($altezzaform-80)) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text ="OK" $OKButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($OKButton) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(10,20) $objLabel.Size = New-Object System.Drawing.Size(280,($altezzaform-100)) $Desktop = (Get-ItemProperty -Path ‘HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\’).Desktop $objLabel.Text = $Lista $objForm.Controls.Add($objLabel) $objForm.Topmost = $True $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() $ErrorActionPreference = "Continue"