Useful Powershell .NET method to convert DNS name to IP

Just thought this was useful, so decided to post it as a reminder for myself or anyone else really.

The reverse being:

Here is how I used it w/ PowerCLI:
$VMHosts = Get-VMhost
$VMHosts | select Name, @{Name="IP";Expression={[]::gethostaddresses($_.Name)}}

This information can be particularly useful if you need IP's for firewall rule tables. Source:


Popular Posts