There is no instance of the Win32_PingStatus class until you actually do a ping. Use this:
gwmi -Query "SELECT * FROM Win32_PingStatus WHERE Address='127.0.0.1'"
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
That is because like I said, there is no instance of the class until you do a query to cause a ping to happen.
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
You mean that you can ping them via the ping command at the command prompt?
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
Ping.exe has no bearing on the Win32_PingStatus WMI class. Ping existed long before WMI was even a glimmer in some engineer's eye. Even if the two were related, here is what would happen (and does happen when you do an explicit query):
Start
-- No instances of Win32_PingStatus exist
Send a ping request to the remote machine
-- An instance of the Win32_PingStatus class poofs into existence
The ping finishes pinging the remote machine
-- The instance of Win32_PingStatus poofs back out of existence
So you see that no matter how many times you do a ping either via ping.exe or via WMI, no permanent instance of the class is ever created.
When you do the explicit query what you are saying to WMI is "PIng this machine and give me back a copy of the instance that gets created."
You can easily test that what you get back is a static copy of the instance by doing this:
1) $foo = gwmi -Query "SELECT * FROM Win32_PingStatus WHERE Address='xx.xxx.xx.xxx'" where you use the ip address of a machine on the network
2)Write-Host $foo.statuscode -- You will see that the machine is on the network
3) Disconnect the machine from the network
4)Write-Host $foo.statuscode -- You will see that the machine is on the network even though it really isn't. This is the first proof that the object stored in $foo is static and in no way represents some sort of dynamic ping object that is constantly updated with the current ping status of the remote machine.
4) If you want further proof, run this command again:
$foo = gwmi -Query "SELECT * FROM Win32_PingStatus WHERE Address='xx.xxx.xx.xxx'"
5)Write-Host $foo.statuscode -- You will see that the machine is not on the network
6) Now hook the machine back up
7) Write-Host $foo.statuscode --You will see that the machine is not on the network even though it is
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.