![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | $ping.send(hostname) pings ipv6 instead of ipv4 address I am having problems with my code working. For whatever reason it tries to ping a hostname, it tries pinging an ipv6 address instead of the ipv4 address, which is returning a status code of 11050 (General Failure). Below is the relevant code. Anyone have an idea on how to make it ping ipv4 instead of ipv6? ## $ping = new-object System.Net.NetworkInformation.Ping $reply = $ping.send("hostname") Write-host "Ping code: $reply.status" Ping code: 11050 ## I would imagine that there is a way to tell it what version of ip to look at, much like you can while in the command prompt: ping hostname -4 or ping hostname -6 Thanks for any help with this. Boe |
My System Specs![]() |
| | #2 (permalink) |
| | Re: $ping.send(hostname) pings ipv6 instead of ipv4 address Hi Boe, you can use following code: $Ping = (Get-WmiObject -Query "Select StatusCode from Win32_PingStatus where address = 'hostname'") Martin "proxb" <boeprox@newsgroup> wrote in message news:4c685174-1727-4de3-9572-df3d6b4bf70a@newsgroup Quote: > I am having problems with my code working. For whatever reason it > tries to ping a hostname, it tries pinging an ipv6 address instead of > the ipv4 address, which is returning a status code of 11050 (General > Failure). Below is the relevant code. Anyone have an idea on how to > make it ping ipv4 instead of ipv6? > > ## > $ping = new-object System.Net.NetworkInformation.Ping > $reply = $ping.send("hostname") > Write-host "Ping code: $reply.status" > > Ping code: 11050 > ## > > I would imagine that there is a way to tell it what version of ip to > look at, much like you can while in the command prompt: ping hostname > -4 or ping hostname -6 > > Thanks for any help with this. > > Boe |
My System Specs![]() |
| | #3 (permalink) |
| | RE: $ping.send(hostname) pings ipv6 instead of ipv4 address Have you tried putting the IP address in and see if it works I did this PS> $ping = New-Object -TypeName System.Net.NetworkInformation.Ping PS> $reply = $ping.Send("127.0.0.1") PS> $reply Status : Success Address : 127.0.0.1 RoundtripTime : 0 Options : System.Net.NetworkInformation.PingOptions Buffer : {97, 98, 99, 100...} which suggests it works on IP4 OK I couldn't find an option to set IP 4 or IP6 -- Richard Siddaway All scripts are supplied "as is" and with no warranty PowerShell MVP Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "proxb" wrote: Quote: > I am having problems with my code working. For whatever reason it > tries to ping a hostname, it tries pinging an ipv6 address instead of > the ipv4 address, which is returning a status code of 11050 (General > Failure). Below is the relevant code. Anyone have an idea on how to > make it ping ipv4 instead of ipv6? > > ## > $ping = new-object System.Net.NetworkInformation.Ping > $reply = $ping.send("hostname") > Write-host "Ping code: $reply.status" > > Ping code: 11050 > ## > > I would imagine that there is a way to tell it what version of ip to > look at, much like you can while in the command prompt: ping hostname > -4 or ping hostname -6 > > Thanks for any help with this. > > Boe > . > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| IPv4 and ipv6 not connected | Network & Sharing | |||
| I can ping with IPv6. I can not ping with IPv4. | Vista General | |||
| Switch the Pinging from IPv6 to Ping IPv4 | Network & Sharing | |||
| Cannot access/ping ipv4 address | Vista networking & sharing | |||
| Wireless N cards do both IPv4 and IPv6? Why? | Vista networking & sharing | |||