bsharath
asked on
How can i find the subnet of a remote machine
Hi,
I want to find the subnet of all machines in the file.
Is there a way to do it remotely.
Regards
Sharath
I want to find the subnet of all machines in the file.
Is there a way to do it remotely.
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.
If you can get replies, that means it is in the subnet of server
ASKER
MrHusy
I just wanted this to be shared with you.
This can get all the details of network card to a file.
Machinenames has to be in the machinelist.txt
Set objExcel = CreateObject("Excel.Applic ation")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Machine Name"
objExcel.Cells(1, 2).Value = "IP Address"
objExcel.Cells(1, 3).Value = "Subnet Mask"
objExcel.Cells(1, 4).Value = "Default Gateway"
objExcel.Cells(1, 5).Value = "MAC Address"
Set Fso = CreateObject("Scripting.Fi leSystemOb ject")
Set InputFile = fso.OpenTextFile("MachineL ist.Txt")
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CimV2")
Set colItems = objWMIService.ExecQuery("S elect * From Win32_NetworkAdapterConfig uration Where IpEnabled = True")
For Each objItem in colItems
strIpAddress = Join(objItem.IpAddress)
strIpSubnet = Join(objItem.IpSubnet)
strDefaultGateway = Join(objItem.DefaultIpGate way)
objExcel.Cells(intRow, 1).Value = UCase(objItem.DnsHostName)
objExcel.Cells(intRow, 2).Value = strIPAddress
objExcel.Cells(intRow, 3).Value = strIPSubnet
objExcel.Cells(intRow, 4).Value = strDefaultGateway
objExcel.Cells(intRow, 5).Value = objItem.MacAddress
intRow = intRow + 1
Next
objExcel.Range("A1:E1").Se lect
objExcel.Selection.Interio r.ColorInd ex = 19
objExcel.Selection.Font.Co lorIndex = 11
objExcel.Selection.Font.Bo ld = True
objExcel.Cells.EntireColum n.AutoFit
loop
Wscript.Echo "Done"
Regards
Sharath
I just wanted this to be shared with you.
This can get all the details of network card to a file.
Machinenames has to be in the machinelist.txt
Set objExcel = CreateObject("Excel.Applic
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Machine Name"
objExcel.Cells(1, 2).Value = "IP Address"
objExcel.Cells(1, 3).Value = "Subnet Mask"
objExcel.Cells(1, 4).Value = "Default Gateway"
objExcel.Cells(1, 5).Value = "MAC Address"
Set Fso = CreateObject("Scripting.Fi
Set InputFile = fso.OpenTextFile("MachineL
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CimV2")
Set colItems = objWMIService.ExecQuery("S
For Each objItem in colItems
strIpAddress = Join(objItem.IpAddress)
strIpSubnet = Join(objItem.IpSubnet)
strDefaultGateway = Join(objItem.DefaultIpGate
objExcel.Cells(intRow, 1).Value = UCase(objItem.DnsHostName)
objExcel.Cells(intRow, 2).Value = strIPAddress
objExcel.Cells(intRow, 3).Value = strIPSubnet
objExcel.Cells(intRow, 4).Value = strDefaultGateway
objExcel.Cells(intRow, 5).Value = objItem.MacAddress
intRow = intRow + 1
Next
objExcel.Range("A1:E1").Se
objExcel.Selection.Interio
objExcel.Selection.Font.Co
objExcel.Selection.Font.Bo
objExcel.Cells.EntireColum
loop
Wscript.Echo "Done"
Regards
Sharath
Hi Sharath
Thanks for your share :). This script works as far as the remote machine is in the same subnet. But it can not get the details of a machine in different subnet because it can not establish a network connectivity to that different subnet.
Regards
Thanks for your share :). This script works as far as the remote machine is in the same subnet. But it can not get the details of a machine in different subnet because it can not establish a network connectivity to that different subnet.
Regards