Hey, great Job! Is it possible to Export only the hostnames? Tried with: $MySubnet = Ping-IPRange -StartAddress 1.1.1.1 -EndAddress 2.2.2.2 -Interval 20 $addis = $MySubnet | ft Ipaddress,@{LABEL="FQDN"; EXPRESSION={[Sy stem.Net.Dns]:: GetHostByAddres s($_.IPaddress) .Hostname}} add-content C:\bat\out.csv $addis any idea?
Hey, is it possible to show the resolved ComputerName with this script? Or is it possible to extend this script for it? Thx in advance
Can I use this to scan outside the subnet of the network I'm on? I am trying to batch rename all computers on my network in order to create a standard and I would like to be able to run this script only once.
Hi CJL84, You can scan any ip address as long as it will reply ICMP request. You could scan the entire internet!
Could you please assist here to do the same quick ping check for Multiple computers in the network. This is very fast and wonderful script to fetch the status quickly. Thanks.
Hi Amol, I hear you, I could modify the script to handle an array of predefined IP addresses. On the other hand, why do you want to modify this script? There are many script out there that are already capable of doing this. For Example you could do something like this: [string[]]$iptargets = "10.0.0.1","10. 0.0.2","10.0.0. 3" [ScriptBlock]$t est_connection = {Test-Connectio n $args -Count 1} $jobs = foreach($iparg in $iptargets){Sta rt-Job -ScriptBlock $test_connectio n -ArgumentList $iparg} Receive-Job -Id $jobs.id -Wait -AutoRemoveJob
I want to run this script from a batch file and export it to a simple txt file. Can someone tell me the best way. Many thanks
I love you script, this is really elegant and definitely fast. One thing I'm missing is the unsuccessful requests, to get them I've modified the condition If($_.SourceEventArgs.Reply.St atus -eq "Success") by If($_.SourceEve ntArgs.Reply.St atus), unfortunately using the regular or Rawoutput, when a request is unsucceful the IP address is 'lost' and return '0.0.0.' this Success 10.6.20.22 3 System.Net.Netw orkInformation. PingOptions {97, 98, 99, 100...} Success 10.6.20.23 3 System.Net.Netw orkInformation. PingOptions {97, 98, 99, 100...} TimedOut 0.0.0.0 0 {} TimedOut 0.0.0.0 0 {} TimedOut 0.0.0.0 0 {} TimedOut 0.0.0.0 0 {} Any idea how to get the IP back for unsuccessful request ? The IP is show in the Write-Progess so there has to be a way.
Hi Cyreli, Glad you like my scrip. Luckily i used the reversed address in the name so i could resolve any event in case some thing went wrong. Now I can use it to get the IP addres back to the event. You can simply replace the $Reply statement in the end of the script. $Reply = Get-Event -SourceIdentifier "ID-Ping*" | ForEach { $_.SourceEventA rgs | select @{ Name="IPAddress " ; Expression={([S ystem.Net.IPAdd ress]($_.UserSt ate.trimstart(' Ping_'))).GetAd dressBytes()[3. .0] -join '.'}}, @{Name="Bytes" ; Expression={$_. Reply.Buffer.Le ngth}}, @{Name="Ttl" ; Expression={$_. Reply.Options.T tl}}, @{Name="Respons eTime"; Expression={$_. Reply.Roundtrip Time}}, @{Name="Status" ; Expression={$_. Reply.Status}} } Have Fun!
I added this to a script of mine that pulls subnets and presents a menu. You select which subnet and it does it's job, shows results, and re-displays the menu. The issue I have is the Header Names are only shown for the first job. Output is correct every time I run it (IP's and reply results) but It will never show the Header again. Any idea's
Hi Koo Amon, I'm glad you like the script and I would like to help you but I can not see what you see. Could you post your script here or on the TechNet forum?
I too am getting this error when I try to run the script on windows 2008 PS D:\Repository\Scripts\Powershe ll\Staging> $PSVersionTable .psversion Major Minor Build Revision ----- ----- ----- -------- 2 0 -1 -1 If it matters...
Hi, I have tried to reproduce this error many times but I have never seen it. Could you please give me the whole error output? By typing $Error[0]|Format-List * -force you get all the data about the last error.
Hi idfkoctgam, I have tested the script on a Server 2008 32bit with a clean install and the same PowerShell version. I still wasn't able to reproduce the error but I have also tested a newer version of the function. Could you please download the new script and test it on your environment? I really appreciate any help getting this bug.
Hi I'm getting this error, when running the script: Cannot convert value "3232235774" to type "System.Int32". Error: "Værdien var enten for stor eller for lille til en Int32." I've typed in 192.168.0.1 as start and 192.168.0.254 as end. The error states, that the value is either too big or too small for an Int32. Question: How do I output the result, fx to an CSV file and can I get the hostnames too for the pinged IP addresses? Br Frank
Hi Frank, That's odd.. The error is correct on the fact that 3232235774 is to big for an Int32, that is why I use an unsigned 32 bit variable, [UInt32]. There a four variable in my function that use an Uint32: $StartAddrInt, $EndAddrInt, $DeltaInt and $x. The function will load in the global scope but the variable in the function are not. If you where to create a variable with the same name as one of the variable in the function PowerShell will not autosense the type it needs to be and it could generate such an error as yours. For the CSV output with hostname you could use the following line: Ping-IPRange -StartAddress 192.168.0.1 -EndAddress 192.168.0.254 | select IPAddress,Bytes,Ttl,ResponseTi me,@{LABEL="Hos tName"; EXPRESSION={[Sy stem.Net.Dns]:: GetHostByAddres s($_.IPaddress) .Hostname}} | Export-Csv .\pingoutput.cs v -NoTypeInformat ion