Hallo,
hier nun das zusammengebaute Skript:
- Es fragt die NICs mit einer IP ab und trägt die Ergebnisse in eine Textdatei ein.
Danke noch mal für die Hilfe!
Grüße
Karsten
Set objWMIService = GetObject("winmgmts:")
Set wnet = CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
Set colNicConfig = objWMIService.ExecQuery("SELECT * FROM " & _
"Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
Const ForAppending = 8
Const ForReading = 1
Const ForWriting = 2
textdateipfad = "C:\"
textdateiname = wnet.ComputerName & ".txt"
On Error Resume next
Set textdatei = fso.CreateTextFile(textdateipfad & textdateiname, True) 'True = Überschreiben
ok = (Err.Number =0)
textdatei.Close
If ok Then
On Error Goto 0
For Each objNicConfig In colNicConfig
If Not IsNull(objNicConfig.IPAddress) Then
strIPAddresses = Join(objNicConfig.IPAddress)
Else
strIPAddresses = ""
End If
If Len(objNicConfig.Index) = 1 Then
nic_intindex = "000" & objNicConfig.Index
ElseIf Len(objNicConfig.Index) = 2 Then
nic_intindex = "00" & objNicConfig.Index
Else
'WScript.Echo nic_intindex
End If
speed = get_nic_speed(nic_intindex)
Set textdatei = fso.OpenTextFile(textdateipfad & textdateiname,ForAppending)
textdatei.WriteLine "Hostname= " & wnet.ComputerName
textdatei.WriteLine "Network Adapter= " & objNicConfig.Index
textdatei.WriteLine "IP Adress(en)= " & strIPAddresses
textdatei.WriteLine "MAC Adresse= " & objNicConfig.MACAddress
textdatei.WriteLine "Description= " & objNicConfig.Description
textdatei.WriteLine "Duplexmodus= " & speed
textdatei.Close
Next
Else
WScript.Echo "Fehler: " & Err.Description
End If
Function get_nic_speed(intindex) 'intindex 4 stellige Indexnummer
Const HKEY_LOCAL_MACHINE = &H80000002
arrmodes = array ("SpeedAndDuplex","SpeedDuplex","ForceSpeedDpx","MediaType","DuplexMode","ConnectionType","RequestedMediaType","ConnectionType_A","ForceSpeedDpx","*SpeedDuplex","EXTPHY")
strComputer = "."
Set oReg=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
Set wshshell = WScript.CreateObject ("wscript.shell")
for each mode in arrmodes
strlink_desc = "ParamDesc"
strkeylink_desc = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"& intindex & "\Ndi\params\" & mode & "\"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strkeylink_desc,strlink_desc,reglink_desc
if reglink_desc <> "" then
strfinal_key = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"& intindex
strfinal_value = mode
oReg.GetStringValue HKEY_LOCAL_MACHINE,strfinal_key,strfinal_value,regfinal_value
strkey_enum = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"& intindex & "\Ndi\params\" & mode & "\enum"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strkey_enum,regfinal_value,speed_name
get_nic_speed = speed_name
End If
Next
End Function