How best to return an Active Directory Computer's IP address


  • Hi there,

    I recently posted a question in the directory services forum about the IPv4Address attribute of an Active Directory computer object.  I can easily (I thought) get them using the activedirectory cmdlets by running:

    Get-ADComputer -filter * -Properties IPv4Address | select name, IPv4Address

    When I run that on the computers in my domain, I found out that about 1/3 of them don't return any value for the IPv4 address.  What I found from the directory services forum is that IPv4Address is NOT an attribute of the object.  It's a value that is "looked up" at the time the cmdlet is run.

    And therein lies my problem.  I'm trying to reconcile A records in our DNS server (which is a Linux server running BIND) with my computer objects and many names do not match.

    What I need is a way to get the ACTUAL IP address from each machine with a computer object in active directory if possible.  My network has Win2k8 R2 domain controllers with about 2/3 Win7 Pro and 1/3 WinXP workstations.  For the most part all are running WinRM/PowerShell 2.0.  Anybody have a clever way to get these IP address from the machines instead of lookup from DNS?

    Thanks in advance for any help you can give me!


    Thursday, March 01, 2012 10:30 PM


  • This will create a list of actual ip addresses found for each computer in the domain:

    $result = @{}
    $computers = Get-ADComputer -Filter * | select -ExpandProperty name 
    foreach ($computer in $computers) {
        try {
            $ipAddress = Test-Connection $computer -Count 1 -ErrorAction stop | select -ExpandProperty ipv4address
            $result.Add($computer, $ipAddress)
            Write-host "$computer offline" -ForegroundColor red
            $result.add($computer, 0)

    Grant Ward, a.k.a. Bigteddy

    What's new in Powershell 3.0 (Technet Wiki)

    Friday, March 02, 2012 5:10 AM

All replies