Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Exception calling "Send" with "1" argument(s) error using PING

Closed Thread
 
Thread Tools Display Modes
Old 07-03-2008   #1 (permalink)
bass_player
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?

 
Old 07-04-2008   #2 (permalink)
Scripting Guru
sapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura about
 
sapienscripter's Avatar
 
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

sapienscripter is offline  
Old 07-04-2008   #3 (permalink)
bass_player
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...
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)
 
Old 07-04-2008   #4 (permalink)
Scripting Guru
sapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura about
 
sapienscripter's Avatar
 
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) {
  $_
 }
  }
}
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 is offline  
Old 07-08-2008   #5 (permalink)
kuma
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:
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)
>
 
 
Closed Thread

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








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49