• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

How can i find which all machines in my network are using static ip address

Hi,

How can i find which all machines in  my network are using static ip address.Is there a way to find this remotely instead of logging to each machine and checking or checking the reservation.As reservation is done for DHCP alloted ip's too.

Regards
Sharath
0
bsharath
Asked:
bsharath
1 Solution
 
Farhan KaziSystems EngineerCommented:
:: *** SCRIPT START ***
@Echo Off
SETLOCAL
IF EXIST C:\StaticIP.txt DEL /F /Q C:\StaticIP.txt
FOR /F "Eol=T Skip=3 Tokens=1 Delims=\ " %%c IN ('Net view') DO (
      Echo Quering: %%c
      WMIC /NODE:"%%c" NICCONFIG WHERE DHCPEnabled=FALSE GET IPAddress | FIND "." >NUL
      IF ErrorLevel 1 Echo %%c is using static IP address >>C:\StaticIP.txt
)
Echo. && Echo Script Finish. Check 'C:\StaticIP.txt' file.
ENDLOCAL
:: *** SCRIPT END ***
0
 
Malli BoppeCommented:
Use the super scan and put the range which you have excluded from the dhcp scope. You should be able to get all the pc names.
http://www.networkingfiles.com/superscan/
0
 
bsharathAuthor Commented:
Farhan

It shows that all the machines are running static ip address.

DEV-CHEN-PC010 is using static IP address
DEV-CHEN-PC011 is using static IP address
DEV-CHEN-PC020 is using static IP address
DEV-CHEN-PC022 is using static IP address
DEV-CHEN-PC025 is using static IP address
DEV-CHEN-PC026 is using static IP address
DEV-CHEN-PC029 is using static IP address
DEV-CHEN-PC030 is using static IP address
DEV-CHEN-PC036 is using static IP address
DEV-CHEN-PC040 is using static IP address
DEV-CHEN-PC043 is using static IP address
DEV-CHEN-PC047 is using static IP address
DEV-CHEN-PC052 is using static IP address
DEV-CHEN-PC057 is using static IP address
DEV-CHEN-PC058 is using static IP address

Where all these machines are switched off or have DHCP enable and i have check them all manually...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
zoofanCommented:
Do you have a list of pcnames that can passed to a script for checking?  If yes I have a script for you

zf
0
 
bsharathAuthor Commented:
Yes i have the names of the machines in a file...
0
 
zoofanCommented:
How about one script to cover the other two questions with this one? output to csv? All nic's installed, dhcp or static, default gateway?


zf
0
 
zoofanCommented:
How about one script to cover the other two questions with this one? output to csv? All nic's installed, dhcp or static, default gateway?


zf
0
 
bsharathAuthor Commented:
Yes that would be great....
0
 
zoofanCommented:
K be back in a few for all three is done and works working on the output formatting so it is better structured

zf
0
 
zoofanCommented:
K be back in a few for all three is done and works working on the output formatting so it is better structured

zf
0
 
zoofanCommented:
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
' ''''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.FileSystemObject")
      Set objWshShell = WScript.CreateObject("WScript.Shell")
      strCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
      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(strPcList) 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(date(),vbshortdate),"/","-")
                                    tme = Replace(Replace(FormatDateTime(now(),vbLongtime),":","-")," ","")
                                          strResultsFile = strCurPath & "\" & tme & "_" & dte & ".csv"
                                                If objFSO.FileExists(strResultsFile) Then
                                                      ObjFSO.deleteFile(strResultsFile)
                                                Else
                                                      Set objOutputFile = objFso.CreateTextFile(strResultsFile)
                                                      objOutputFile.Close      
                                                End If
                                                MsgBox strResultsFile
                                    Set objPCnames = objFso.GetFile(strPcList)
                                    Set objReadFile = objPCnames.OpenAsTextStream(ForReading, TristateUseDefault)
                                          Do Until objReadFile.AtEndOfStream
                                                ReDim Preserve arrPCnames(intLneCount)
                                                arrPCnames(intLneCount) = objReadFile.ReadLine
                                                intLneCount = intLneCount + 1
                                          Loop
                                    objReadFile.Close
                                          Set objOutputFile = objFso.OpenTextFile(strResultsFile,ForWriting,TristateUseDefault)
                                          objOutputFile.WriteLine("Computer,Nic#,Description,DHCP,IP,Mask,Gateway")
                                                For intPCLoop = LBound(arrPCnames) To UBound(arrPCnames)
                                                      strTestcon = IsServerOn(arrPCnames(intPCLoop))
                                                      If strTestcon = "0" then                                                
                                                      strReturn = getnetinfo(arrPCnames(intPCLoop))
                                                      objOutputFile.WriteLine(strReturn)
                                                      Else
                                                      objOutputFile.WriteLine(arrPCnames(intPCLoop) & "," & 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=impersonate}!\\" & strcomputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
intNics = 0
For Each objNicConfig In colNicConfigs

  If Not IsNull(objNicConfig.IPAddress) Then
    strIPAddresses = Join(objNicConfig.IPAddress)
  Else
    strIPAddresses = "None"
  End If
  If Not IsNull(objNicConfig.IPSubnet) Then
    strIPSubnet = Join(objNicConfig.IPSubnet)
  Else
    strIPSubnet = "None"
  End If
  If Not IsNull(objNicConfig.DefaultIPGateway) Then
    strDefaultIPGateway = Join(objNicConfig.DefaultIPGateway)
  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.FileSystemObject")
            Set objTxtLines = objFso.GetFile(strTxtFile)
            Set objReadFile = objTxtLines.OpenAsTextStream(ForReading, 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
0
 
zoofanCommented:
Opps forgot the end copy for sanity

'===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
' ''''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.FileSystemObject")
      Set objWshShell = WScript.CreateObject("WScript.Shell")
      strCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
      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(strPcList) 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(date(),vbshortdate),"/","-")
                                    tme = Replace(Replace(FormatDateTime(now(),vbLongtime),":","-")," ","")
                                          strResultsFile = strCurPath & "\" & tme & "_" & dte & ".csv"
                                                If objFSO.FileExists(strResultsFile) Then
                                                      ObjFSO.deleteFile(strResultsFile)
                                                Else
                                                      Set objOutputFile = objFso.CreateTextFile(strResultsFile)
                                                      objOutputFile.Close      
                                                End If
                                                MsgBox strResultsFile
                                    Set objPCnames = objFso.GetFile(strPcList)
                                    Set objReadFile = objPCnames.OpenAsTextStream(ForReading, TristateUseDefault)
                                          Do Until objReadFile.AtEndOfStream
                                                ReDim Preserve arrPCnames(intLneCount)
                                                arrPCnames(intLneCount) = objReadFile.ReadLine
                                                intLneCount = intLneCount + 1
                                          Loop
                                    objReadFile.Close
                                          Set objOutputFile = objFso.OpenTextFile(strResultsFile,ForWriting,TristateUseDefault)
                                          objOutputFile.WriteLine("Computer,Nic#,Description,DHCP,IP,Mask,Gateway")
                                                For intPCLoop = LBound(arrPCnames) To UBound(arrPCnames)
                                                      strTestcon = IsServerOn(arrPCnames(intPCLoop))
                                                      If strTestcon = "0" then                                                
                                                      strReturn = getnetinfo(arrPCnames(intPCLoop))
                                                      objOutputFile.WriteLine(strReturn)
                                                      Else
                                                      objOutputFile.WriteLine(arrPCnames(intPCLoop) & "," & 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=impersonate}!\\" & strcomputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
intNics = 0
For Each objNicConfig In colNicConfigs

  If Not IsNull(objNicConfig.IPAddress) Then
    strIPAddresses = Join(objNicConfig.IPAddress)
  Else
    strIPAddresses = "None"
  End If
  If Not IsNull(objNicConfig.IPSubnet) Then
    strIPSubnet = Join(objNicConfig.IPSubnet)
  Else
    strIPSubnet = "None"
  End If
  If Not IsNull(objNicConfig.DefaultIPGateway) Then
    strDefaultIPGateway = Join(objNicConfig.DefaultIPGateway)
  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.FileSystemObject")
            Set objTxtLines = objFso.GetFile(strTxtFile)
            Set objReadFile = objTxtLines.OpenAsTextStream(ForReading, 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
'===END copy: getlaninfo.vbs===

any problems let me know,


zf
0
 
zoofanCommented:
Will return DHCP True/False for each adapter installed physical and virtual.

zf
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now