Using the Test-Connection in an enterprise environment, I often miss the -a parameter of the old ping command, that tells ping to try to resolve IP address to HostName.
So I sat down and created a proxy function for Test-Connection, adding a Resolve parameter. It’s quite simple actually, it’s checks the ComputerName parameter, and if the data is a valid IP address tries to resolve using the Net.Dns class. It then takes the resolved name and injects it back into the ComputerName parameter before calling the original Test-Connection command.
There is one drawback of using proxies with the same name as existing commands though, and that is that Get-Help with not work as you are used to. There is two ways of “fixing” this problem:
- Call Get-Help like this:
Get-Help Test-Connection -Category Function
- Add the following line to your PowerShell profile:
(Get-Command Microsoft.PowerShell.Management\Test-connection).Visibility = 'Private'