Asked By Thorsten A. Oeltjen
18-Mar-10 11:20 AM

Hi
within a script i'm trying to ping a host. if it is reachable, the script
can go on.
'magic cap'
for this posting *g*
the script gave me back errors - i tried within the console and found
that there was an error in
the dns server. Okay - we fixed that and before we made an ipconfig
/flushdns i tried a little bit.
I expect, that if i use the IP-Adress of the host, a ping should always
work (if the host is up).
I thought so. Its different ... see below ...
My Question - how is ist possible that if i ping an ip-adress -
powershell resolves the name bound to
it an then back to the wrong ip-adress???
The statuscode was sometimes 11003 (host not reachable) or 0.
My problem - i have trust my programm if it says : sry - host ist not
reachable ...
because its intended to work as an automated script, deleting unised
files ...
........................................................................................................................................................................
Skriptsniplet
........................................................................................................................................................................
clear
function FunTest($TargetHost)
{
$return = Get-WmiObject Win32_PingStatus -filter
return ($return.statuscode)
}
$TargetHost = "10.40.61.10"
if (FunTest($TargetHost) -eq 0)
{
Write-Host "Target ist da"
}
else
{
Write-Host "Target ist nicht da"
}
........................................................................................................................................................................
/Skriptsniplet
........................................................................................................................................................................
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. Alle Rechte vorbehalten.
PS C:\Users\> $Targethost = "10.40.61.10"
PS C:\Users\> Get-WmiObject Win32_PingStatus -filter
protocoladdress
statuscode responsetime
---------------
---------- ------------
10.40.61.10
0 13
PS C:\Users\thorsten.oeltjen> $Targethost = "deingfle01"
PS C:\Users\thorsten.oeltjen> Get-WmiObject Win32_PingStatus -filter
protocoladdress
statuscode responsetime
---------------
---------- ------------
11010
........................................................................................................................................................................
........................................................................................................................................................................
PS C:\Users\> ping-host 10.40.61.10
Pinging <name>.<fqn> [192.168.61.1] with 32 bytes of data:
DestinationHostUnreachable
TimedOut
DestinationHostUnreachable
TimedOut
Ping statistics for <name>.<fqn>:
Packets: Sent = 4 Received = 0 (100% loss)
Approximate round trip time: min = 0ms, max = 0ms, avg = 0ms
PS C:\Users\thorsten.oeltjen> ping 10.40.61.10
Pinging <name>.<fqn> [192.168.61.1] with 32 bytes of data:
TimedOut
TimedOut
TimedOut
DestinationHostUnreachable
Ping statistics for <name>.<fqn>:
Packets: Sent = 4 Received = 0 (100% loss)
Approximate round trip time: min = 0ms, max = 0ms, avg = 0ms
PS C:\Users\> ping.exe 10.40.61.10
Ping wird ausgef?hrt f?r 10.40.61.10 mit 32 Bytes Daten:
Antwort von 10.40.61.10: Bytes=32 Zeit=14ms TTL=254
Antwort von 10.40.61.10: Bytes=32 Zeit=4ms TTL=254