'Objective: Display servername, IP address, fully qualified domain name of the give server" 'Created by: MAK 'Created Date: June 18, 2005 'Save this File as FQDN.vbs 'Usage: cscript fqdn.vbs server1 on error resume next Set objArgs = WScript.Arguments ServerName=objArgs(0) wscript.echo ServerName + "," +pingable(ServerName)+","+FQDN(pingable(ServerName)) if err.number >0 then wscript.echo ServerName + ",?,?" end if Function Pingable(strHost) Dim objExec, objRE set objshell = wscript.createobject("wscript.shell") blnPingable = "False" 'assume failure Set objExec = objShell.Exec("cmd /C ping -n 1 " & strHost) string1 = objExec.StdOut.ReadAll if instr(1,string1,"TTL=",1) >0 then Pingable = True else pingable =false end if if pingable =True then Chaine = "[" Chaine2 = "]" ValueSearch = InStr(1,string1,Chaine,1) ValueSearch2 = InStr(valuesearch,string1,Chaine2,1) If ValueSearch>=1 and ValueSearch2>1 Then y= mid(string1,ValueSearch+1,(ValueSearch2-ValueSearch)-1) else pingable="false" End If pingable = replace(y,"Pinging ","") pingable = replace(pingable," ","") if pingable =false or pingable="" then pingable ="False" end if end if Set objExec = Nothing Set objRE = Nothing End Function Function FQDN(strHost) Dim objExec, objRE set objshell = wscript.createobject("wscript.shell") blnPingable = "False" 'assume failure Set objExec = objShell.Exec("cmd /C nslookup " & strHost) string1 = objExec.StdOut.ReadAll if instr(1,string1,"Name:",1) >0 then FQDN = True else FQDN =false end if if FQDN =True then Chaine = "Name:" Chaine2 = "Address" ValueSearch = InStr(1,string1,Chaine,1) ValueSearch2 = InStr(valuesearch,string1,Chaine2,1) If ValueSearch>=1 and ValueSearch2>1 Then y= mid(string1,ValueSearch+1,(ValueSearch2-ValueSearch)-1) else FQDN="false" End If FQDN = replace(y,"ame:","") FQDN = replace(FQDN," ","") if FQDN =false or FQDN="" then FQDN="False" end if end if Set objExec = Nothing Set objRE = Nothing End Function