bsharath
asked on
I want to find all the machines in the file how many network cards they have.
Hi,
I want to find all the machines in the file how many network cards they have.
Machinename Networcard name Ip address Enabled/Disabled.
Is there a way to get such details.
Regards
Sharath
I want to find all the machines in the file how many network cards they have.
Machinename Networcard name Ip address Enabled/Disabled.
Is there a way to get such details.
Regards
Sharath
ASKER
Yes Farhan you are right.Network ip address does not generate in your previous script.If you can add this and change the format a bit that would be useful as when i scan 100's of machines with the previous script it becomes difficult to read
You should try this program called spiceworks, it is totally free and you can have it scan and generate reports. One of the reports it can run is to see how many network adapters machines have, what ip they have, DHCP or static and if they are disabled or not. Let me know if this works.
http://www.spiceworks.com/
http://www.spiceworks.com/
Do you have a list of pcnames to pass to a script?
zf
zf
ASKER
Yes i have the machine names in a file...
K be back in a few for all three is done and works working on the output formatting so it is better structured
zf
zf
I hope this fits the bill for all accounts, I think youll like the result.
'===Start copy: getlaninfo.vbs===
' -------------------------- ---------- ---------- ---------- -------'
' getlaninfo.vbs
' 'Sample VBScript to query remote computers
' 'and return lan adapter information into csv file.
' ''Author Riley C. aka ZooFan
' '''Version 1.6 - August 2007
' ''''https://www.experts-exchange.com question ID: 22749974,22749966,22748871
' -------------------------- ---------- ---------- ---------- -------'
'
Option Explicit
Const ForReading = 1, ForWriting = 2, ForAppending = 3 'FileObject Access Type
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 'FileObject Format Type
Dim strPcList
Dim arrPcnames()
Dim strResultsFile
Dim dte
Dim tme
Dim objFso
Dim objWshShell
Dim objPCnames
Dim objReadFile
Dim intLneCount
Dim objOutputFile
Dim strCurPath
Dim intPCLoop
Dim strReturn
Dim strTestcon
Set objFso = CreateObject("Scripting.Fi leSystemOb ject")
Set objWshShell = WScript.CreateObject("WScr ipt.Shell" )
strCurPath = CreateObject("Scripting.Fi leSystemOb ject").Get AbsolutePa thName("." )
strPcList = InputBox("Please enter the full path and file" & VbCrLf & "name of the file with the computer names.","Get cdrom drives.")
'Test to make sure file exists if not exit script
If Not objFso.FileExists(strPcLis t) Then
MsgBox "You must enter a valid full path and file name!",vbOKOnly,"Get cdrom drives."
WScript.Quit(0)
Elseif strPcList = "" Then
MsgBox "You must enter a filename!",vbOKOnly,"Get cdrom drives."
WScript.Quit(0)
Else 'File exists continue
dte = Replace(FormatDateTime(dat e(),vbshor tdate),"/" ,"-")
tme = Replace(Replace(FormatDate Time(now() ,vbLongtim e),":","-" )," ","")
strResultsFile = strCurPath & "\" & tme & "_" & dte & ".csv"
If objFSO.FileExists(strResul tsFile) Then
ObjFSO.deleteFile(strResul tsFile)
Else
Set objOutputFile = objFso.CreateTextFile(strR esultsFile )
objOutputFile.Close
End If
MsgBox strResultsFile
Set objPCnames = objFso.GetFile(strPcList)
Set objReadFile = objPCnames.OpenAsTextStrea m(ForReadi ng, TristateUseDefault)
Do Until objReadFile.AtEndOfStream
ReDim Preserve arrPCnames(intLneCount)
arrPCnames(intLneCount) = objReadFile.ReadLine
intLneCount = intLneCount + 1
Loop
objReadFile.Close
Set objOutputFile = objFso.OpenTextFile(strRes ultsFile,F orWriting, TristateUs eDefault)
objOutputFile.WriteLine("C omputer,Ni c#,Descrip tion,DHCP, IP,Mask,Ga teway")
For intPCLoop = LBound(arrPCnames) To UBound(arrPCnames)
strTestcon = IsServerOn(arrPCnames(intP CLoop))
If strTestcon = "0" then
strReturn = getnetinfo(arrPCnames(intP CLoop))
objOutputFile.WriteLine(st rReturn)
Else
objOutputFile.WriteLine(ar rPCnames(i ntPCLoop) & "," & strTestcon)
End If
Next
objOutputFile.Close
MsgBox("Script has completed")
WScript.Quit
End If
Function getnetinfo(strcomputer)
On Error Resume Next
Dim objWMIService
Dim colNicConfigs
Dim objNicConfig
Dim strIPAddresses
Dim strIPSubnet
Dim strDefaultIPGateway
Dim strGatewayCostMetric
Dim intNics
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strcomputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = True")
intNics = 0
For Each objNicConfig In colNicConfigs
If Not IsNull(objNicConfig.IPAddr ess) Then
strIPAddresses = Join(objNicConfig.IPAddres s)
Else
strIPAddresses = "None"
End If
If Not IsNull(objNicConfig.IPSubn et) Then
strIPSubnet = Join(objNicConfig.IPSubnet )
Else
strIPSubnet = "None"
End If
If Not IsNull(objNicConfig.Defaul tIPGateway ) Then
strDefaultIPGateway = Join(objNicConfig.DefaultI PGateway)
Else
strDefaultIPGateway = "None"
End If
intNics = intNics + 1
If intNics = 1 Then
getnetinfo = getnetinfo & strcomputer & "," & intNics & "," & objNicConfig.Description & "," & objNicConfig.DHCPEnabled & "," & strIPAddresses & "," & strIPSubnet & "," & strDefaultIPGateway & VbCrLf
Else
getnetinfo = getnetinfo & "," & intNics & "," & objNicConfig.Description & "," & objNicConfig.DHCPEnabled & "," & strIPAddresses & "," & strIPSubnet & "," & strDefaultIPGateway & VbCrLf
End If
Next
Set objWMIService = Nothing
Set colNicConfigs = Nothing
End Function
Function IsServerOn(strserver)
Dim Testme
Dim intErr
Dim strRegValue
Dim strFileServer
On Error Resume Next
Set Testme = GetObject("winmgmts://" & strserver & "/root/cimv2")
Set strRegValue = GetObject("winmgmts://" & strserver & "/root/default:StdRegProv" )
intErr = Err.Number
If intErr <> 0 Then
IsServerOn = Err.Description
Else
IsServerOn = "0"
End If
On Error GoTo 0
End Function
Function readtextfile(strTxtFile, arrname())
On Error Resume Next
Dim intErr, intLines
Dim objTxtLines, objReadFile,objFso
Set objFso = CreateObject("Scripting.Fi leSystemOb ject")
Set objTxtLines = objFso.GetFile(strTxtFile)
Set objReadFile = objTxtLines.OpenAsTextStre am(ForRead ing, TristateUseDefault)
Do Until objReadFile.AtEndOfStream
ReDim Preserve arrname(intLines)
arrname(intLines) = objReadFile.ReadLine
intLines = intLines + 1
Loop
objReadFile.Close
Set objFso = nothing
Set objTxtLines = Nothing
Set objReadFile = Nothing
intErr = Hex(Err.Number)
If intErr <> 0 Then
readtextfile = Err.Description
Else
readtextfile = "0"
End If
On Error GoTo 0
End Function
any problems let me know,
zf
'===Start copy: getlaninfo.vbs===
' --------------------------
' getlaninfo.vbs
' 'Sample VBScript to query remote computers
' 'and return lan adapter information into csv file.
' ''Author Riley C. aka ZooFan
' '''Version 1.6 - August 2007
' ''''https://www.experts-exchange.com question ID: 22749974,22749966,22748871
' --------------------------
'
Option Explicit
Const ForReading = 1, ForWriting = 2, ForAppending = 3 'FileObject Access Type
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 'FileObject Format Type
Dim strPcList
Dim arrPcnames()
Dim strResultsFile
Dim dte
Dim tme
Dim objFso
Dim objWshShell
Dim objPCnames
Dim objReadFile
Dim intLneCount
Dim objOutputFile
Dim strCurPath
Dim intPCLoop
Dim strReturn
Dim strTestcon
Set objFso = CreateObject("Scripting.Fi
Set objWshShell = WScript.CreateObject("WScr
strCurPath = CreateObject("Scripting.Fi
strPcList = InputBox("Please enter the full path and file" & VbCrLf & "name of the file with the computer names.","Get cdrom drives.")
'Test to make sure file exists if not exit script
If Not objFso.FileExists(strPcLis
MsgBox "You must enter a valid full path and file name!",vbOKOnly,"Get cdrom drives."
WScript.Quit(0)
Elseif strPcList = "" Then
MsgBox "You must enter a filename!",vbOKOnly,"Get cdrom drives."
WScript.Quit(0)
Else 'File exists continue
dte = Replace(FormatDateTime(dat
tme = Replace(Replace(FormatDate
strResultsFile = strCurPath & "\" & tme & "_" & dte & ".csv"
If objFSO.FileExists(strResul
ObjFSO.deleteFile(strResul
Else
Set objOutputFile = objFso.CreateTextFile(strR
objOutputFile.Close
End If
MsgBox strResultsFile
Set objPCnames = objFso.GetFile(strPcList)
Set objReadFile = objPCnames.OpenAsTextStrea
Do Until objReadFile.AtEndOfStream
ReDim Preserve arrPCnames(intLneCount)
arrPCnames(intLneCount) = objReadFile.ReadLine
intLneCount = intLneCount + 1
Loop
objReadFile.Close
Set objOutputFile = objFso.OpenTextFile(strRes
objOutputFile.WriteLine("C
For intPCLoop = LBound(arrPCnames) To UBound(arrPCnames)
strTestcon = IsServerOn(arrPCnames(intP
If strTestcon = "0" then
strReturn = getnetinfo(arrPCnames(intP
objOutputFile.WriteLine(st
Else
objOutputFile.WriteLine(ar
End If
Next
objOutputFile.Close
MsgBox("Script has completed")
WScript.Quit
End If
Function getnetinfo(strcomputer)
On Error Resume Next
Dim objWMIService
Dim colNicConfigs
Dim objNicConfig
Dim strIPAddresses
Dim strIPSubnet
Dim strDefaultIPGateway
Dim strGatewayCostMetric
Dim intNics
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig
intNics = 0
For Each objNicConfig In colNicConfigs
If Not IsNull(objNicConfig.IPAddr
strIPAddresses = Join(objNicConfig.IPAddres
Else
strIPAddresses = "None"
End If
If Not IsNull(objNicConfig.IPSubn
strIPSubnet = Join(objNicConfig.IPSubnet
Else
strIPSubnet = "None"
End If
If Not IsNull(objNicConfig.Defaul
strDefaultIPGateway = Join(objNicConfig.DefaultI
Else
strDefaultIPGateway = "None"
End If
intNics = intNics + 1
If intNics = 1 Then
getnetinfo = getnetinfo & strcomputer & "," & intNics & "," & objNicConfig.Description & "," & objNicConfig.DHCPEnabled & "," & strIPAddresses & "," & strIPSubnet & "," & strDefaultIPGateway & VbCrLf
Else
getnetinfo = getnetinfo & "," & intNics & "," & objNicConfig.Description & "," & objNicConfig.DHCPEnabled & "," & strIPAddresses & "," & strIPSubnet & "," & strDefaultIPGateway & VbCrLf
End If
Next
Set objWMIService = Nothing
Set colNicConfigs = Nothing
End Function
Function IsServerOn(strserver)
Dim Testme
Dim intErr
Dim strRegValue
Dim strFileServer
On Error Resume Next
Set Testme = GetObject("winmgmts://" & strserver & "/root/cimv2")
Set strRegValue = GetObject("winmgmts://" & strserver & "/root/default:StdRegProv"
intErr = Err.Number
If intErr <> 0 Then
IsServerOn = Err.Description
Else
IsServerOn = "0"
End If
On Error GoTo 0
End Function
Function readtextfile(strTxtFile, arrname())
On Error Resume Next
Dim intErr, intLines
Dim objTxtLines, objReadFile,objFso
Set objFso = CreateObject("Scripting.Fi
Set objTxtLines = objFso.GetFile(strTxtFile)
Set objReadFile = objTxtLines.OpenAsTextStre
Do Until objReadFile.AtEndOfStream
ReDim Preserve arrname(intLines)
arrname(intLines) = objReadFile.ReadLine
intLines = intLines + 1
Loop
objReadFile.Close
Set objFso = nothing
Set objTxtLines = Nothing
Set objReadFile = Nothing
intErr = Hex(Err.Number)
If intErr <> 0 Then
readtextfile = Err.Description
Else
readtextfile = "0"
End If
On Error GoTo 0
End Function
any problems let me know,
zf
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Will create one info entry for each installed adapter, physical and virtual.
zf
zf
https://www.experts-exchange.com/questions/22658952/Find-no-of-network-cards-a-machine-has.html