Results 1 to 2 of 2

Thread: Script to obtain IP address

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Norwich, UK.
    Posts
    304

    Script to obtain IP address

    Hi,

    I have the following script to obtain an IPAddress from a laptop when it logs onto the domain. It works fine unless the laptop has more than one Ethernet (ie: wireless).

    Does anyone know how to modify the script so that it ONLY returns the IP address of the internal LAN NIC and ignores Bluetooth, Wireless etc etc?

    Ideally, script it to extract the IP where the DNS Suffix is our domain name, as shown from ipconfig in a command line for example.

    Here is the script:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set IPConfigSet = objWMIService.ExecQuery _
    ("Select IPAddress from Win32_NetworkAdapterConfiguration Where DHCPEnabled=TRUE")

    For Each IPConfig in IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then
    For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
    WScript.Echo IPConfig.IPAddress(i)

    Next
    End If
    Next
    Last edited by ShiftySid; Jul 23rd, 2008 at 05:48 AM.

  2. #2
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: Script to obtain IP address

    Hi Sid,
    I made a new thread accidently.

    Mods, could you please merge the thread?
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width