xouvang
asked on
Powershell Resolve list of IP to host name
Hi,
I have a list of IP addresses (around 400 IP addresses) that I need to find the host name.
The script I have right now is
But this is not getting the results of what I want. That code will only output the host name if the IP address is valid. Some IP addresses are not valid. This gives me a hard time trying to find out what is what.
Is there a way to have powershell resolve ip to host name and find out which user last used that workstation? Is it possible to out put it in this format?
Client Address Host Name User
10.10.10.10 Computer 1 ssmith
10.10.10.11 Cannot resolve hostname bjohn
Here is what I was able to find
https://www.experts-exchange.com/questions/27741224/powershell-script-to-get-IPs-of-a-list-of-computer-hostnames.html
I'm trying to do the opposite of that.
Thanks!
I have a list of IP addresses (around 400 IP addresses) that I need to find the host name.
The script I have right now is
Get-Content C:\IP_Address.txt | ForEach-Object {([system.net.dns]::GetHostByAddress($_)).hostname >> c:\hostname.txt}
But this is not getting the results of what I want. That code will only output the host name if the IP address is valid. Some IP addresses are not valid. This gives me a hard time trying to find out what is what.
Is there a way to have powershell resolve ip to host name and find out which user last used that workstation? Is it possible to out put it in this format?
Client Address Host Name User
10.10.10.10 Computer 1 ssmith
10.10.10.11 Cannot resolve hostname bjohn
Here is what I was able to find
https://www.experts-exchange.com/questions/27741224/powershell-script-to-get-IPs-of-a-list-of-computer-hostnames.html
I'm trying to do the opposite of that.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome. Thanks too and good luck.
ASKER
Open in new window
I guess I'll go ahead and make another script to get last logged users.
Thanks!