Can’t say if getting the IP address from DNS is the best option, however try looking at the “Get-DnsServerResourceRecord”-cmdlet within the “DnsServer” module where your DNS is located (properly on your domain controller).
Then you could easily loop through the output from the Get-ADComputer and get the corresponding IP address of every computer from the “Get-DnsServerResourceRecord”-cmdlet.
That’s to get you started. Keep in mind DNS can return multiple IP addresses for a host; I’m not sure if or how you’ll want to deal with that, so this example doesn’t try. Resolve-DnsName also returns an object; you might want to extract the IP address property values instead of jamming the whole object into a property, as my example does.
Why not get the IP address directly from AD? The field name is called IPv4Address.
Also if you think the client has old Windows 2000 servers you should make the filter: “WindowsServer”.
Thank you to you all.
PowerShell rocks And i realy have to spend a lot of time learning it well:) (But for now its pretty hard).
Don: You where talking about extract the IP address property value. Is that something like this: -expandproperty IPAddress? If so, where to put it. Have tried it at the end, but dont give me anything
I implement a lot a of new customers in our datacenter. And to do this if the customer dont have an overview them self realy save me a lot of time. Thanks a lot for the starting point Don.