govi
01-09-2002, 11:04 PM
Hi All,
Here is a code which I have got while browsing the net. This script when run give us basic info of a remote computer........
Since I have not written the script on my own, I have not understood some(infact many) parts of the code....
On Error Resume next
dim objLocator, objSvc, wshNet
set wshNet=CreateObject("Wscript.Network")
strTitle="IP Configuration"
strNameSpace="root\cimv2" ----->What does this mean ?
strServer=Inputbox("Enter a computername to query",strTitle,wshNet.Computername)
msgbox strServer
If strServer="" Then
wscript.echo "Nothing entered for servername or you cancelled."
wscript.quit
End If
If strServer=wshNet.ComputerName Then
strUser=""
strPassword=""
Else
strUser=Trim(Inputbox("Enter a user name that has admin rights on " &strServer,strTitle,wshNet.UserName))
If strUser="" Then
wscript.echo "Nothing entered for username or you cancelled"
wscript.quit
End If
strPassword=Trim(Inputbox("Enter in the appropriate password which is CaSe SensiTive",strTitle,"password"))
If strPassword="" Then
wscript.echo "Nothing entered for password (blank passwords not allowed) or you cancelled"
wscript.quit
End If
End If
Set objLocator=CreateObject("WbemScripting.SWbemLocator") ------>Is there such an oject ?
Set objSvc=objLocator.ConnectServer(strServer,strNames pace,strUser,strPassword)----->Same as above..
If err.number<>0 Then
wscript.echo "There was an error connecting to " & UCASE(strServer) & VBCRLF & _
"Make sure you specified the correct credentials and/or a valid server name." & VBCRLF & _
"Error #" & err.number & " - " & err.description
wscript.quit
End If
Err.Clear
objSvc.Security_.ImpersonationLevel=3 ----->Dont have much clue about this one too...
strQuery="Select * from win32_NetworkAdapterConfiguration where IPEnabled=True"-----> Does such a query exist ?
Set objResults=objSvc.ExecQuery(strQuery,,0) -----> No clue at all....
If err.number<>0 Then
wscript.echo "There was an error executing the query on " & UCASE(strServer) & _
VBCRLF & "Error #" & err.Number and " - " & err.Description
wscript.quit
End If
s="Server Name: " & UCASE(strServer) & VBCRLF
for each objInstance in objResults
strDNS="not defined"
if LEN("x" & objInstance.DNSDomain)<2 Then
strDNS="not defined"
else
strDNS=objInstance.DNSDomain
end if
s=s & "DNS Domain: " & strDNS & VBCRLF
s=s & "Desc: " & objInstance.Description & VBCRLF
s=s & "IPAddress: " & objInstance.IPAddress(0) & VBCRLF
s=s & "Subnet Mask: " & objInstance.IPSubnet(0) & VBCRLF
strGW=""
if objInstance.DefaultIPGateway(0)=" " Then
strGW="not defined"
else
strGW=objInstance.DefaultIPGateway(0)
end if
s=s & "IP Gateway: " & strGW & VBCRLF
s=s & "MAC: " & objInstance.MACAddress & VBCRLF
s=s & VBCRLF
next
wscript.echo s
set objInstance=Nothing
set objSvc=Nothing
set wshNEt=Nothing
set objLocator=Nothing
wscript.quit
Also I would like this script to give me some additional details like, IP of DHCP server, WINS server, Secondary WINS server. Is this possible ?
Thanx in advance :-)
Here is a code which I have got while browsing the net. This script when run give us basic info of a remote computer........
Since I have not written the script on my own, I have not understood some(infact many) parts of the code....
On Error Resume next
dim objLocator, objSvc, wshNet
set wshNet=CreateObject("Wscript.Network")
strTitle="IP Configuration"
strNameSpace="root\cimv2" ----->What does this mean ?
strServer=Inputbox("Enter a computername to query",strTitle,wshNet.Computername)
msgbox strServer
If strServer="" Then
wscript.echo "Nothing entered for servername or you cancelled."
wscript.quit
End If
If strServer=wshNet.ComputerName Then
strUser=""
strPassword=""
Else
strUser=Trim(Inputbox("Enter a user name that has admin rights on " &strServer,strTitle,wshNet.UserName))
If strUser="" Then
wscript.echo "Nothing entered for username or you cancelled"
wscript.quit
End If
strPassword=Trim(Inputbox("Enter in the appropriate password which is CaSe SensiTive",strTitle,"password"))
If strPassword="" Then
wscript.echo "Nothing entered for password (blank passwords not allowed) or you cancelled"
wscript.quit
End If
End If
Set objLocator=CreateObject("WbemScripting.SWbemLocator") ------>Is there such an oject ?
Set objSvc=objLocator.ConnectServer(strServer,strNames pace,strUser,strPassword)----->Same as above..
If err.number<>0 Then
wscript.echo "There was an error connecting to " & UCASE(strServer) & VBCRLF & _
"Make sure you specified the correct credentials and/or a valid server name." & VBCRLF & _
"Error #" & err.number & " - " & err.description
wscript.quit
End If
Err.Clear
objSvc.Security_.ImpersonationLevel=3 ----->Dont have much clue about this one too...
strQuery="Select * from win32_NetworkAdapterConfiguration where IPEnabled=True"-----> Does such a query exist ?
Set objResults=objSvc.ExecQuery(strQuery,,0) -----> No clue at all....
If err.number<>0 Then
wscript.echo "There was an error executing the query on " & UCASE(strServer) & _
VBCRLF & "Error #" & err.Number and " - " & err.Description
wscript.quit
End If
s="Server Name: " & UCASE(strServer) & VBCRLF
for each objInstance in objResults
strDNS="not defined"
if LEN("x" & objInstance.DNSDomain)<2 Then
strDNS="not defined"
else
strDNS=objInstance.DNSDomain
end if
s=s & "DNS Domain: " & strDNS & VBCRLF
s=s & "Desc: " & objInstance.Description & VBCRLF
s=s & "IPAddress: " & objInstance.IPAddress(0) & VBCRLF
s=s & "Subnet Mask: " & objInstance.IPSubnet(0) & VBCRLF
strGW=""
if objInstance.DefaultIPGateway(0)=" " Then
strGW="not defined"
else
strGW=objInstance.DefaultIPGateway(0)
end if
s=s & "IP Gateway: " & strGW & VBCRLF
s=s & "MAC: " & objInstance.MACAddress & VBCRLF
s=s & VBCRLF
next
wscript.echo s
set objInstance=Nothing
set objSvc=Nothing
set wshNEt=Nothing
set objLocator=Nothing
wscript.quit
Also I would like this script to give me some additional details like, IP of DHCP server, WINS server, Secondary WINS server. Is this possible ?
Thanx in advance :-)