Jump to content

Recommended Posts

Posted (edited)

I need to check if computers is online. I used to use ping for things like this:

if ping($ComputerNamesList[$i]) <> 0 Then
... some code
EndIf

But sometimes there is DNS error. I mean you want to ping computer A but you actually pinging computer B. That's because that computer was not shuted down properly. Sometimes you need to wait a few weeks before the wrong DNS record will be gone (or you just need to turn the computer off properly). But my question is how can I check if computers are online if there is DNS issue happens from time to time?

Edited by minimen456
Posted

Don't ping the computer by name but by IP-address.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Make sure you assign the computer a static IP address.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

Thank you for responds guys. I think I solved this problem. I found out that ConnectServer always fails when there is DNS issue with computer. You simply can't connect to computer with wrong $ComputerName. So I can double check ping() function. If $objWMIService is not an object then there is DNS issue.

$objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator")
$objWMIService = $objSWbemLocator.ConnectServer($ComputerName, "\ROOT\CIMV2", "login", "pass")

p.s If someone not satisfied he can obtain computer name through WMI and compare it with one that have been used to call ping() function

p.s I hope my English is not that bad and you guys actually understood what I meant

Edited by minimen456

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...