bsharath
asked on
Convert the list of Ip's to machine names.
Hi,
I have a list of ip's in a txt file.IS there a way to convert all of them to Machinenames next to the ip address.
Regards
Sharath
I have a list of ip's in a txt file.IS there a way to convert all of them to Machinenames next to the ip address.
Regards
Sharath
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Farhan Sorry for the delay.
Your code is working fine.
ghostdog74
I get this.
C:\>cscript /nologo "ip's to machine names.vbs" > newfile
C:\ip's to machine names.vbs(6, 7) Microsoft VBScript runtime error: The remote
server machine does not exist or is unavailable: 'GetObject'
I think we need more error checking...
Your code is working fine.
ghostdog74
I get this.
C:\>cscript /nologo "ip's to machine names.vbs" > newfile
C:\ip's to machine names.vbs(6, 7) Microsoft VBScript runtime error: The remote
server machine does not exist or is unavailable: 'GetObject'
I think we need more error checking...
On error resume Next
Set objFSO=CreateObject("Scrip ting.FileS ystemObjec t")
myIPs = "c:\temp\ips.txt" 'your ip list
Set objFile = objFSO.OpenTextFile(myIPs, 1)
Do Until objFile.AtEndOfLine
strComputer = objFile.ReadLine
Set objWMIService = GetObject("winmgmts:{imper sonationLe vel=impers onate}!\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery("S ELECT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = True")
For Each objAdapter in colAdapters
If Not IsNull(objAdapter.IPAddres s) Then
For i = 0 To UBound(objAdapter.IPAddres s)
WScript.Echo objAdapter.IPAddress(i) & ":" & objAdapter.DNSHostName
Next
End If
Next
Loop
Set objFSO=CreateObject("Scrip
myIPs = "c:\temp\ips.txt" 'your ip list
Set objFile = objFSO.OpenTextFile(myIPs,
Do Until objFile.AtEndOfLine
strComputer = objFile.ReadLine
Set objWMIService = GetObject("winmgmts:{imper
Set colAdapters = objWMIService.ExecQuery("S
For Each objAdapter in colAdapters
If Not IsNull(objAdapter.IPAddres
For i = 0 To UBound(objAdapter.IPAddres
WScript.Echo objAdapter.IPAddress(i) & ":" & objAdapter.DNSHostName
Next
End If
Next
Loop
Set objFSO=CreateObject("Scrip
myIPs = "c:\temp\ips.txt" 'your ip list
Set objFile = objFSO.OpenTextFile(myIPs,
Do Until objFile.AtEndOfLine
strComputer = objFile.ReadLine
Set objWMIService = GetObject("winmgmts:{imper
Set colAdapters = objWMIService.ExecQuery("S
For Each objAdapter in colAdapters
If Not IsNull(objAdapter.IPAddres
For i = 0 To UBound(objAdapter.IPAddres
WScript.Echo objAdapter.IPAddress(i) & ":" & objAdapter.DNSHostName
Next
End If
Next
Loop
usage: c:\> cscript /nologo myscript.vbs > newfile