Command to get IP address based on computer name

Hello Experts,

I use

Open in new window

to get the IP address of a server.
I will like to find a command to do it the opposite. Enter the IP and get the primary computer name of the server.
I tried net stat and nslookup but it doesn’t work.
If you have a cmd or a powershell command to get this straightforward I am in.
Thank you very much for your help.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FOXActive Directory/Exchange EngineerCommented:
If you have your dns set up correctly all you have to do is:
ping "ipaddress" -a

ping -a
JohnBusiness Consultant (Owner)Commented:
Assuming this is on the same subnet, get Advanced IP Scanner (Famatech - free) and scan with that. It gives you this plus other information.
Sam JacobsDirector of Technology Development, IPMCommented:
$hostName = ([System.Net.Dns]::gethostentry("IP Address")).HostName

Open in new window

PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

LD16Author Commented:
Thank you Sam, this command is powershell or cmd?
Sam JacobsDirector of Technology Development, IPMCommented:
This assumes you want to query machines in your own network. For external machines, if they don't have a PTR entry in the respective reverse lookup zone, there's nothing you can do.
If you don't get a response from nslookup, you don't seem to have a reverse lookup zone in your DNS, or the machine isn't registered there. In this case, other methods relying on DNS won't help, either.
For Windows target machines, you can try PowerShell and WMI:
(Get-WmiObject -Class Win32_ComputerSystem -ComputerName '').Name

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
If I understand, I think this is what you're after...

# nslookup
> set q=ptr

Non-authoritative answer:	name =

Open in new window

LD16Author Commented:
Ok, I was able to get my solution with ping the problem was that name server use an specific eur domain due to this the command doesn't work.  ping adrdressname.eur -a works!
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Your question was about translating an IP to a host name.

The command you list above translates a host name to IP.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.