![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest
Posts: n/a
| Exception calling "Send" with "1" argument(s) error using PING I have a PowerShell script which uses the System.Net.NetworkInformation.Ping object. It reads thru a text file of hostnames and does a PING test. What I'm curious about is that I get this error every now and then, meaning no error on first three hostnames from the list, error on the next, etc. Exception calling "Send" with "1" argument(s): "An exception occurred during a Ping request." At line 5, position 22 $Reply = $ping.send($strComputer) A forum post from the MSDN forum says its by design. https://forums.microsoft.com/MSDN/Sh...=8895&SiteID=1 Am I missing something? |
| | #2 (permalink) |
| Scripting Guru ![]() ![]() ![]() ![]() Join Date: Jun 2008 Vista Ultimate 32bit
Posts: 32
Location: Syracuse, NY | Re: Exception calling "Send" with "1" argument(s) error using PING It made sense to me and I'm not even a .NET developer. Couldn't you simply use an error trap and if you get that error, then know you can't ping that computer for some reason. A ping alternative is to use the win32_pingstatusclass: PS C:\> get-wmiobject -query "Select * from win32_pingstatus where address='godot'" __GENUS : 2 __CLASS : Win32_PingStatus __SUPERCLASS : __DYNASTY : Win32_PingStatus __RELPATH : Win32_PingStatus.Address="godot",BufferSize=32,NoFrag olveAddressNames=FALSE,SourceRoute="",SourceRouteType TimeToLive=128,TypeofService=0 __PROPERTY_COUNT : 24 __DERIVATION : {} __SERVER : PUCK __NAMESPACE : root\cimv2 __PATH : \\PUCK\root\cimv2:Win32_PingStatus.Address="godot",Bu ,RecordRoute=0,ResolveAddressNames=FALSE,SourceRoute= ,TimestampRoute=0,TimeToLive=128,TypeofService=0 Address : godot BufferSize : 32 NoFragmentation : False PrimaryAddressResolutionStatus : 0 ProtocolAddress : 172.16.10.101 ProtocolAddressResolved : RecordRoute : 0 ReplyInconsistency : False ReplySize : 32 ResolveAddressNames : False ResponseTime : 1 ResponseTimeToLive : 128 RouteRecord : RouteRecordResolved : SourceRoute : SourceRouteType : 0 StatusCode : 0 Timeout : 4000 TimeStampRecord : TimeStampRecordAddress : TimeStampRecordAddressResolved : TimestampRoute : 0 TimeToLive : 128 TypeofService : 0 |
| | |
| |
| | #3 (permalink) | ||||||||||||
| Guest
Posts: n/a
| Re: Exception calling "Send" with "1" argument(s) error using PING Thanks for the inputs. I'm trying to monitor computers and servers, check if they're running before I run a script. I'm trying to convert all of my VBScripts to PowerShell :-) "sapienscripter" <guest@xxxxxx-email.com> wrote in message news:262c35e123e2972b98259f9e65b304a5@xxxxxx-gateway.com...
| ||||||||||||
| | #4 (permalink) |
| Scripting Guru ![]() ![]() ![]() ![]() Join Date: Jun 2008 Vista Ultimate 32bit
Posts: 32
Location: Syracuse, NY | Re: Exception calling "Send" with "1" argument(s) error using PING Here's a function that might help. Code: Function Ping-Host {
PROCESS {
$errorActionPreference="SilentlyContinue"
$wmi = get-wmiobject -query “SELECT * FROM Win32_PingStatus WHERE Address = '$_'"
if ($wmi.StatusCode -eq 0) {
$_
}
}
}
"localhost" | ping-host or get-content servers.txt | ping-host If the computer can be pinged, the name is written to the pipeline. Moving from VBScript to PowerShell requires a paradigm shift as much as anything. |
| | |
| |
| | #5 (permalink) | ||||||||||||
| Guest
Posts: n/a
| Re: Exception calling "Send" with "1" argument(s) error using PING If you're computers are setup to not respond to ICMP echoes you can try this, I can't remember where I found it at the moment. function Test-Port { param([string]$srv,$port=135,$timeout=750,[switch]$verbose=$false) $ErrorActionPreference = "SilentlyContinue" $tcpclient = new-Object System.Net.Sockets.TcpClient $iar = $tcpclient.BeginConnect($srv,$port,$null,$null) $wait = $iar.AsyncWaitHandle.WaitOne($timeout,$false) if(!$wait) { $tcpclient.Close() if($verbose){Write-Host "Connection Timeout"} Return $false } else { $error.Clear() $tcpclient.EndConnect($iar) | out-Null if($error[0]){if($verbose){write-host $error[0]};$failed = $true} $tcpclient.Close() } if($failed){return $false}else{return $true} } This will allow you to specify a specific port on a specific machine. I use it to see if the ports for telnet, ssh, etc.. are open so i can close them. But you could use it instead of a ping. -- It says "Press Any Key To Continue..." but I can''''t find the "Any" key...... "sapienscripter" wrote:
| ||||||||||||
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unwanted Multiple contacts in "To","CC","BCC" of email send catago | xsailer | Vista mail | 1 | 3 Weeks Ago 08:34 AM |
| Vista not wotking with "My Computer" or "Control Panel", "Screen Saver" | Platebanger | Vista General | 6 | 02-05-2008 08:54 AM |
| How can I add the icons "Delete", "Cut", "Copy" and "Paste" in Vis | Moonwalker | Vista file management | 7 | 09-17-2007 05:55 PM |
| WM5 Sync with Vista "Windows Calender", "Contacts", and "Mail" | Tony | Vista General | 1 | 02-16-2007 06:20 PM |
| interesting "issue" or "bug" with psobjects when calling DOTNET framework stuff | klumsy@xtra.co.nz | PowerShell | 0 | 11-09-2006 05:18 PM |