{"id":89,"date":"2006-09-14T09:33:36","date_gmt":"2006-09-14T07:33:36","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=89"},"modified":"2007-01-03T07:05:39","modified_gmt":"2007-01-03T05:05:39","slug":"ping-script","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=89","title":{"rendered":"Ping script"},"content":{"rendered":"<p>This script ping different machines. If a machine\u00c2\u00a0dont answer a local event will ge generated. If you set strLog to 1 a event\u00c2\u00a0will\u00c2\u00a0be\u00c2\u00a0generated for every successful ping.\u00c2\u00a0 You will need to create a parameter named Hosts that contains all hosts you want to ping.<\/p>\n<p><code>'<br \/>\n' If strLog = \"1\" then a event will be generated for<br \/>\n' success ping.<br \/>\n'<br \/>\n' This script use one parameter called \"Hosts\".<br \/>\n' Value for this can be like this<br \/>\n' ping.sunet.se,10.1.1.0<br \/>\n'<br \/>\n' Version 2.0<\/code><code> <\/code><\/p>\n<p><code \/><code>aMAchines = Split(ScriptContext.Parameters.Get(\"Hosts\"), \",\")<br \/>\nstrLog = \"0\"<\/code><code>For Each machine in aMachines<br \/>\nSet objPing = GetObject(\"winmgmts:{impersonationLevel=impersonate}\")._<br \/>\nExecQuery(\"select * from Win32_PingStatus where address = '\"_<br \/>\n& machine & \"'\")<br \/>\nFor Each objStatus in objPing<br \/>\nIf IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then<\/code><code> <\/code><code>Const EVENT_WARNING = 2<br \/>\nSet objShell = CreateObject(\"Wscript.Shell\")<br \/>\nobjShell.LogEvent EVENT_WARNING, _<br \/>\n\"Computer \" & machine & \" is not reachable (\" & strLog & \")\"<\/p>\n<p>ELSE<br \/>\nIF strLog = 1 Then<br \/>\nConst EVENT_SUCCESS = 0<br \/>\nSet objShell = CreateObject(\"Wscript.Shell\")<br \/>\nobjShell.LogEvent EVENT_SUCCESS, _<br \/>\n\"Computer \" & machine & \" is reachable\"<\/p>\n<p>End If<br \/>\nEnd If<br \/>\nNext<br \/>\nNext<\/p>\n<p>\u00c2\u00a0<\/p>\n<p><\/code>\u00c2\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This script ping different machines. If a machine\u00c2\u00a0dont answer a local event will ge generated. If you set strLog to 1 a event\u00c2\u00a0will\u00c2\u00a0be\u00c2\u00a0generated for every successful ping.\u00c2\u00a0 You will need to create a parameter named Hosts that contains all hosts you want to ping. &#8216; &#8216; If strLog = &#8220;1&#8221; then a event will be &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=89\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[2,13],"tags":[],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/89"}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89"}],"version-history":[{"count":0,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}