ping-host output

Topics: Developer Forum, User Forum
Mar 31, 2007 at 12:34 AM
I have been attempting to use the PSCX extention ping-host in some of my PowerShell scripts but with some frustrating results. I attempt to ping, using ping-host, prior to excuting further code. I have all the logic working but I can't seem to control the output generated by ping-host appropriately. I get all the reply attempts written to the console. When all I really want is a verification that the host is up or down. I am using code similar to this:

if ($(ping-host -count 3 -timeout 30).received -eq 3)
	Write-Host "Host is UP"
} else {
	Write-Host "Host is DOWN"

With output like this:

Pinging with 32 bytes of data:
    Reply from bytes=32 time=0ms TTL=128
    Reply from bytes=32 time=0ms TTL=128
    Reply from bytes=32 time=0ms TTL=128
Host is UP

When the only intended output would be "Host is UP". Am I missing a parameter or method or something that can control this "Reply..." output?

Mar 31, 2007 at 7:22 AM
Yeah I think we probably screwed up on this one since the cmdlet writes the ping replies directly to the host. I'm converting this to a work item. Perhaps we can address this for the upcoming 1.1.1 release.
Mar 31, 2007 at 7:23 AM
This discussion has been copied to Work Item 9281. You may wish to continue further discussion there.
Mar 31, 2007 at 9:43 AM
reedj, use the -async parameter to disable output of the individiual ping replies.