Thanks, that was a big help. I think I am almost there but having issues combining the 2.
For the ping part, if I run the script below I get the appropriate response...
START
Option Explicit
Dim strHost
' Check that all arguments required have been passed.
If Wscript.Arguments.Count < 1 Then
Wscript.Echo "Arguments <Host> required. For example:" & vbCrLf _
& "cscript vbping.vbs savdaldc01"
Wscript.Quit(0)
End If
strHost = Wscript.Arguments(0)
if Ping(strHost) = True then
Wscript.Echo "Host " & strHost & " contacted"
Else
Wscript.Echo "Host " & strHost & " could not be contacted"
end if
Function Ping(strHost)
dim objPing, objRetStatus
set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address = '" & strHost & "'")
for each objRetStatus in objPing
if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode<>0 then
Ping = False
'WScript.Echo "Status code is " & objRetStatus.StatusCode
else
Ping = True
'Wscript.Echo "Bytes = " & vbTab & objRetStatus.BufferSize
'Wscript.Echo "Time (ms) = " & vbTab & objRetStatus.ResponseTime
'Wscript.Echo "TTL (s) = " & vbTab & objRetStatus.ResponseTimeToLive
end if
next
End Function
FINISH
And I can also use this email script and get an email out...
START
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "my email address"
objEmail.To = "my email address"
objEmail.Subject = "Server down"
objEmail.Textbody = "Server1 is no longer accessible over the network."
objEmail.Configuration.Fields.Item _
("
= 2
objEmail.Configuration.Fields.Item _
("
= _
"my SMTP server"
objEmail.Configuration.Fields.Item _
("
= 25
objEmail.Configuration.Fields.Update
objEmail.Send
FINISH
To try and combine the 2 I want to replace the ELSE command with the email script but I get an error saying the objEmail is not defined