![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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? |
My System Specs![]() |
| | #2 (permalink) |
| Vista Ultimate 32bit | 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 |
My System Specs![]() |
| | #3 (permalink) |
| | 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... Quote: > > 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 > > > -- > sapienscripter > > Coming Soon: -'Managing Active Directory with Windows PowerShell: TFM' > (http://www.sapienpress.com/ad.asp)- > > '[image: http://www.scriptinganswers.com/_images/logo_mvp.gif]' > (http://www.scriptinganswers.com/_images/logo_mvp.gif) > > 'My Blog' (http://blog.sapien.com/) > 'FollowMe on Twitter' (http://www.twitter.com/JeffHicks) ![]() |
My System Specs![]() |
| | #4 (permalink) |
| Vista Ultimate 32bit | 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. |
My System Specs![]() |
| | #5 (permalink) |
| | 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: Quote: > > 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) { > $_ > } > } > } > -------------------- > > > This is designed to take pipeline input. > > "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. > > > -- > sapienscripter > > Coming Soon: -'Managing Active Directory with Windows PowerShell: TFM' > (http://www.sapienpress.com/ad.asp)- > > '[image: http://www.scriptinganswers.com/_images/logo_mvp.gif]' > (http://www.scriptinganswers.com/_images/logo_mvp.gif) > > 'My Blog' (http://blog.sapien.com/) > 'FollowMe on Twitter' (http://www.twitter.com/JeffHicks) ![]() > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Exception calling "CreateInstance" with "2" argument(s): for Microsoft.Update.UpdateColl | PowerShell | |||
| Unwanted Multiple contacts in "To","CC","BCC" of email send catago | Vista mail | |||
| Vista not wotking with "My Computer" or "Control Panel", "Screen Saver" | Vista General | |||
| WM5 Sync with Vista "Windows Calender", "Contacts", and "Mail" | Vista General | |||
| interesting "issue" or "bug" with psobjects when calling DOTNET framework stuff | PowerShell | |||