My Profile Photo

${Graham Beer} = 'blog'

Infrastructure Engineer, authored chapter in the PowerShell Conference Book, co-founder of the PowerShell user group in the South Coast and Top 50 Blogger 2018

PowerShell Conf Book Planet PowerShell Top 50 PowerShell

PS Function : IP to Hostname / Hostname to IP

Here is a short reusable function that came about when I recently had an error popup with just an IP address.

Turned out it was error many users were getting that caused a problem in the company. From the IP address I wanted to get the Hostname to ask the Wintel department if they knew of this Server.  I could have simply used the “Ping” command with a ‘-a’ option, but I wanted to find a way in PowerShell and create a function as a simply to use tool. As I was creating a function to find a Hostname from an IP why not do the reverse as well and get the IP from a Hostname. This is what I did, and by using the .NET class, “”, was able to achieve this. I hope you find it of some use in your day to day troubleshooting !


Get-NetDetails -HostName
Get-NetDetails -IP